518 Posted Topics
Re: >If i use long for j instead of int will it work??? Yes Edit: [U]Why?[/U] 100001*100001=10000200001 So obviously a int cannot hold this number. Adding UL won't solve the thing Edit2: I realized that adding UL does solved the problem. I am don't think it is good. You should rather … | |
Re: Read [url]http://bytes.com/groups/cpp/62066-c-programmers-how-do-you-use-unnamed-namespaces[/url] and [url]http://www.gamedev.net/community/forums/topic.asp?topic_id=535626[/url] Edit: a more appropriate document [url]http://winterdom.com/dev/cpp/nspaces[/url] | |
Re: He said he want a open source compiler. First of all, Congratulations for choosing Open Source. G++ is accepted as the most widely used open source compiler. You can use it on M$ Windows too. MinGW is just a port of G++ for M$ windows. Both are nearly same thing. … | |
Re: >Better open this specifically in input mode mode as He is doing fine: he declared the object of ifstream hence it is fine not to mention ios::in To OP: a. You coding is what use to be 15 years ago. I think it is time to change. Read [URL="http://siddhant3s.googlepages.com/how_to_tell_rusted_cpp.html"]this[/URL]. If … | |
Re: >[wow I am still laughing at my opening statement] Which statement? Anyways, it would be very tough to troubleshoot if your code is sacred. Try to produce similar code which causes similar error then post it. Saying anything without code would be senseless. | |
| |
Re: Hint: ord('\x1a')=26 ord('\x05')=5 ord() is a built-in function which returns the ASCII value of the passed charachter. Edit: @ vegaseat: [code=python] #python 2.5.2 >>> c="%s" % '\x1a' >>> c '\x1a' >>> print c #nothing gets printed [/code] | |
Re: While you are searching for the solution, you should know that [URL="http://www.parashift.com/c++-faq-lite/containers.html#faq-34.1"]arrays are evil[/URL]. You should be working on STL's std::vector instead of traditional array. The following document can help you migrate : [url]http://siddhant3s.googlepages.com/how_to_tell_rusted_cpp.html#SECTION00052000000000000000[/url] | |
Re: >While you're at it, could you tell me why line 7 is invalid syntax? Line 7 would have made sense if you had followed the proper syntax of the code tags: [noparse][code=python] // the code which goes here will have // line numbers at left side [/code][/noparse] Anyways, it turns … | |
Re: @Tux4life Your beautiful post has nothing to do with OP's problem. The construct use for allocating space using malloc is absolutely valid in C. The only problem is on line: void* ptr = buf_ptr[20]; as Beair.GQ said, you are assigning a void to void*. The type of buf_ptr[i] is not … | |
Re: How are you compiling? I compiled your project and it ran fine: [code] g++ main.cpp fubar.cpp -o output.exe [/code] | |
Re: Okay, You know what is function overloading in C++, do you? Lets say you create a function named [U][I]int greater(int a, int b)[/I][/U] which returns the greater of the two integer of either [I]a[/I] and [I]b[/I]. You define it as [code=cpp] int greater(int a, int b) { if( a> b) … | |
Re: Low-level programming isn't sexy anymore. What you are refereing to is machine language. Every one uses it, in a way that all highlevel instructions are actually processed by CPU as machine instruction. Machine languages are introduced as just for educational purpose. The famous example is the ``Art of Computer Programming" … | |
Re: Depending on your platform, you can time your application for a given set of data. Or you can use a [URL="http://en.wikipedia.org/wiki/Performance_analysis"]profiler[/URL] . But whatever you do, please don't optimize your code without analyzing its performance. Optimize only and only when you really need it. | |
![]() | Re: >I know it has to be a loop, but which function? Why are you so sure? [code=python] >>> s="asdf<script" >>> print s[:s.find('<')] asdf >>> [/code] |
Re: Works for me: g++ on Linux [code=cpp]#include<iostream> #include<string> static const char * sql_backslash_to_underscore(const char * key) { if (!key) { //ERROR0("got NULL key"); return NULL; } std::string rep = key; std::replace(rep.begin(), rep.end(), '\', '_'); return rep.c_str(); } int main() { std::cout<<sql_backslash_to_underscore("acct\\username"); }[/code] [code] siddhant3s@Xion:~$ g++ tester.cpp -o tester siddhant3s@Xion:~$ ./tester … | |
Re: Your problem, what I am perceiving is, that you want to have an interface for your class which can return the c-string for [I]name[/I] but don't let user change it. Returning a pointer is not a good idea overall. Change your signature of the get function as: [code=cpp] void getName(char* … | |
Re: OMG, the OP is answering his own question..... oh wait..... So you are twins !! That took me a while after noticing that you both share the same avatar. > as you know for an array > &array[0] = array, > so we just pass in the name of the … | |
Re: >I dont know which one to download from where and how to use it. So, [URL="http://www.all-acronyms.com/STFW"]STFW.[/URL]. Salem has already told you twice to use curses( or ncurses or pdcurses) but look at you.... you are not even bothered. | |
Re: >I'd suggest a final step of randomly shuffling the values. That can complicate things. I would suggest OP that: after assigning values 0 to 9 to all those 20 location, choose a location randomly and assign value zero to it. | |
Re: >static arrays are ............ You meant to say "fixed-length" arrays, right? OP>in here i cant set the array size from function receiving argument? and why? Because, array size should be a compile time constant, that is: the array size should be known at the compile time. You are already been … | |
Re: >Can ne1 tell me how 2 write a c++ program to find out the determinant of a (mxn ) >matrix Determinants are only defined for square matrix. A far as writing of the program is concerned: [U]"NO ONE IS GOING TO WRITE IT AND DELIVER IT TO YOU"[/U] The [U]ONE[/U] … | |
Re: I won't have to. When you create an object of class C, both get_a, get_b will be available for calling. If however, both function was named get(), then it would cause ambiguity. [code]class A { protected: int no; public: void get(void) { cout<<"Class"; } }; class B { protected: int … | |
Re: Recursive functions is almost never a good idea if you are aiming for speed. Recursive functions however, are easier to conceptualize than iterative functions. They goes with philosophy ``Developers time is far more important than machine time." However, on languages such as C, C++ recursive functions are not 'so bad' … | |
Re: Use urllib to fetch the ftp directory: [code=python] >>> a=urlopen('ftp://ftp.cs.stanford.edu/pub/cweb/') >>> a=a.read() >>> print a drwxr-xr-x 3 ftp users 4096 Oct 24 2006 . drwxr-xr-x 49 sybase sybase 4096 Dec 11 2008 .. -rw-r--r-- 1 ftp users 4962 Dec 29 2003 Makefile -rw-r--r-- 1 ftp users 4950 Feb 14 2002 … | |
Re: Just add [icode]typname[/icode] before [icode]RangeToValidatorMap::const_iterator it;[/icode] to make it [icode]typename RangeToValidatorMap::const_iterator it;[/icode] Now try to find out using web, why this fixed the problem. Get back here if you don't find anything. | |
Re: Your not catching the value return by the function. [code=cplusplus]#include <iostream> using namespace std; enum months {jan = 1, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec}; months nextMonth(months& currentMonth); int main() { months a = nov; a=nextMonth(a); cout << a << endl; return 0; } months … | |
Re: >Can anyone tell me the answer? Or if it can not be done? ArkM has beautifully answered your question. Open your mind to see this. I would again like to point out ArkM's last point: If you are a C++ programmer, you should know that Macros are evil. Look at … | |
Re: Each program on specific operating system is alloted its own memory space which is usually parted into 3 components: stack, heap and data. When you say that you know the value at location 0x245CEA20, You may be mistaken!! Suppose I have a variable named [I]a[/I] in a program A which … | |
Re: If it bothers you, try to be expressive while writing your code: Use iterators. learn the reverse iterators at [url]http://www.cplusplus.com/reference/string/string/rbegin/[/url] After you read the example there, study the following code: [code=cplusplus]bool isrev(string s1,string s2) { string::reverse_iterator rit; string::iterator it; if(s1.size()!=s2.size()) return false; for ( rit=s1.rbegin(),it=s2.begin(); rit < s1.rend()&&it<s2.end(); rit++,it++ ) … | |
Re: Ok, What you want is a bit informal explanation. Think of stream as a virtual device (presumably a printer). You are give functions to read/write to that device. You actually don't differentiate if that device is actually your monitor, your printer, the hard disk, or the RAM. What you know … | |
Re: >Sometimes the simplest solution is the best one. Sometimes simplest solution is not the portable one. Your solution lean on grep to be available. [code=python]f=open('file.txt'); lines=f.readlines(); for l in lines: # remove .lstrip() from the following next line, if you don't want to be strict. # Any whitespace wont stripped … | |
Re: >How do we output value in register AX? How can you be so sure that your computer has a register? C++, or any compiler doesn't know about registers. C++ also runs on those computer which doesn't have registers. So, don't go at much lower level with a language as C++. | |
Re: >thanks man, a million thanks. It works So, what is stopping you to mark the thread as Solved. | |
Re: [QUOTE=PcPro12]mine is probably the space bar, since I always use it to press space......[/QUOTE] Yeah, but we use space bar key to press delete. Me a Emacs user: What can you expect. The left control key. There is nothing written on it. Space has gotten much older but there was … | |
Re: >As C++ developer - stop finding ready-made code or solution otherwise you will >mess up your work. "Good programmers know what to write. Great ones know what to rewrite (and reuse)." He is not looking for "homework helps". He is trying to exercise what is one of the well known … | |
Re: The whole concept of Template is to exploit the fact that interface of the data-type passed is same. Consider std:;sort() it takes the vector of any container which have overloaded > operator. That is, template are used to perform type-unspecific operations. If you are needing a way to check if … | |
Re: Use simple boolean statements. Here is my python interaction: [code=python] >>> a = [1,2,3,4,5,6,7,8,9,10,10,10] >>> b = list(input ("Enter numbers: ")) Enter numbers: [3,4,10] >>> a= [x for x in a if x not in b] >>> a [1, 2, 5, 6, 7, 8, 9] >>> [/code] | |
Re: Try not to confuse people. Those who knows python does not necessarily know bash. The same way you know bash but do not know python. BTW, here is your code: [code=python] s="dani_web_needs_better_OP" print s.split("_")[1] [/code] One more advice, try to read a book. These things are covered in the introductory … | |
Re: [U]About negative subscript in arrays and array notations[/U] Consider the following code: [code=c]#include<stdio.h> int main() { int ia[]={0,1,2,3,4,5,6,7};/*a normal array*/ int* ip=&ia[4];/*a pointer pointing to 5th element*/ /*WRONG: will print garbage. Unpredictable value*/ printf("%i \n",ia[-3]); /*OK. Prints 1*/ printf("%i \n",ip[-3]); return 0; }[/code] The Line 11 will be interpreted as … | |
Re: Look at lines dvd movie; movie(lista); in int main() What do you want [U]movie[/U] to be: a function or a [I]dvd[/I] structure?. Use a different name for the object or a different name for the function. Note that it is alright to declare a dvd called movie in main(). But … | |
Re: >the main prob is i m a beignner and i have to submit my assignment soon Your only problem is that you have NOT read a book. Go and get one and read it. You have not impressed us a bit so that we should help you. also read [URL="http://www.catb.org/~esr/faqs/smart-questions.html"]How … | |
Re: This is for you: Click [URL="http://www.youfail.org/"]Here[/URL] | |
Re: >>But I dont know the correct way to do it? What you are doing is ``just" acceptable. It is no where near to what one would called a good code. I suggest you to use the infamous Unix philosophy KISS( Keep it Simple and Stupid). Although I am not a … | |
Re: Simple, Use file I./O. Or you can also use the input redirection operator '<' while calling the program from the command prompt [icode]$ myprogram.exe < input_data.txt[/icode] | |
Re: >I can't understand why your brutal force algorithm is so expensive It will certainly not be. But he may be getting 100 of Input tests at once. So it may exceed the time limit ( which is about 2-3 seconds ). | |
Re: To tux:[url]http://www.cplusplus.com/reference/iostream/istream/getline/[/url] "Characters are extracted until either (n - 1) characters have been extracted or the delimiting character is found (which is delim if this parameter is specified, or '\n' otherwise). The extraction also stops if the end of file is reached in the input sequence or if an error … | |
Re: Now thats what I call a script kiddie. >I Can Program basic Online Codez :CSS and HTML. You do not program in HTML. HTML is not a programming language. It is a markup language. Consider yourself quite lucky. Because hackers don't usualy repsonz 2 sm1 who cnnt wrte pr0per1y. Plz … | |
Re: Oh man! Did anyone told you that you should have been using the post tags: [noparse] [code=cplusplus] //paste the code here [/code] [/noparse] Anyways, your code is awful. I am sure you would be programming in a Old-style compiler (perhaps TC++ ). Read this:[url]http://cppdb.blogspot.com/2008/10/why-you-shouldnt-use-you-use-old-c.html[/url] You have not coded the main() … | |
Re: The first optimization advice is "[URL="http://c2.com/cgi/wiki?PrematureOptimization"]Don't optimize anything[/URL]". Second advice: Stick to one language C or C++. You are using lot of scanfs and printfs. It goes without say that post your code it code tags: [noparse] [code=cpp] //your code [/code] [/noparse] |
The End.