6,741 Posted Topics
Re: divides is a standard function object defined in <functional>, and Dev-C++ is better at not letting you do stupid things than the [B]older[/B] Borland C++ 5.5 (which is what I assume you're using). | |
Re: >char a = 'abcde' would be legal right? If the implementation allows a character literal like that then it's perfectly legal. However, the result is not the same as an array consisting of the characters 'a','b','c', and 'd' in any case. >Or can a single char only hold 1 char? … | |
Re: How about you explain what you're trying to do? My first impression is that your code is broken due to several misconceptions about how strings work. >for (int j = 0 ; j <=sizeof(RW[j]); j++) sizeof RW[j] is 1. Always. >for (int i = 0 ; i <=sizeof(array[i]); i++) sizeof … | |
Re: >I Have One Doubt. No, you have a question. A doubt is not a question. A doubt is skepticism, you know the answer but still don't believe it or know just enough of the answer to be uncertain of its truth. A question is an inquiry for the purpose of … | |
Re: >I asked some of our friends in the C/C++ Forum at DaniWeb Who gave you the answer you asked for but not the answer you were looking for. C's nesting limit has nothing to do with Python's nesting limit. But the cold hard fact of the matter is that Python … | |
Re: There are no certifications that matter. If you want to be "certified", make a name for yourself by helping with high profile projects and doing a good job. | |
Re: >all the information on System() is just confusing to me It's just a command interpreter. Pass it a string just like you would your shell and things will happen. :rolleyes: Intuitively, system is one of the simplest functions. | |
Re: >Hi I am in III yr engg. >Any1 wid any Please try to use proper spelling and grammar. Not everyone who reads these forums is a native English speaker and those people will find your silly abbreviations impossible to decipher. >programming experience on steganography and/or Virtual Private Networking, please help. … | |
Re: %ld is a long integer. You can add a field width that specifies the minimum number of characters to print. So %5ld will pad numbers with fewer than five digits using spaces. You can add a precision using a period and another number that specifies the minimum number of digits … | |
Re: Quadratic probing uses a quadratically growing increment that's added to the address. So if you have address 30, you would start with an increment of 1. If 31 is occupied, you square the increment to 2 and try address 33. If 33 is occupied, you square the increment to 4 … | |
Re: >What's the difference between the two? The difference is how you access the object, how long the object lives, and where it's stored. | |
Re: >Is there any way to resize a console program while its running [url=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/setconsoledisplaymode.asp]Perhaps[/url]. >also whats a better way to clear the console then The best way to clear the console is to not clear the console. But if you must, there really isn't a good way, so pick whichever you … | |
Re: >I tried using blah ( tree -> rightp ) Why? tree->rightp is a node*, but the function expects a node** because you typedef'd Treep to be a node*, and blah asks for a Treep*. The progression is like this: Treep becomes struct node* so Treep* becomes struct node** So you … | |
Re: >I was wondering which lang is best for game designing. It depends on what kind of games. You'll get the most mileage out of C and C++, but Java, Python, and assembly might play important roles as well. | |
Re: >Create three float arrays A, B and C with 500000000 elements Assuming that float is four bytes, you're looking at 6 gigs worth of storage. Your timing will be way off because of thrashing. A better solution would be to do a fraction of this and then multiply it into … | |
Re: user_r.r and user_r.l are Point objects. The < operator isn't defined for them. You need to change your comparison to use user_r.r.x and user_r.r.y and likewise for user_r.l. | |
Re: You need to convert the tokens to integer values before you can do an easy range check on them: [code] #include <stdio.h> #include <stdlib.h> #include <string.h> #define RANGE 50 int main ( void ) { char string[] = "6565,4325,7074,7897,7685,3478"; const char *seps = " ,"; char *token; int target; printf … | |
![]() | Re: >will anything that is passed to whatever be assigned to x_ using the initializing list? Assuming whatever is a compatible initializer for x_, yes. |
Re: It sounds like you have a building issue rather than a code issue. It links and runs just fine for me on Visual Studio .NET 2003. Try making a new project and pasting your code into it, then let us know if it worked or not. | |
Re: This works, with only minor changes to your original code. Remember that things you do once are outside of the loop, the sum has to start at 0 to give you any useful information, and the basic idea is to add num to sum until num equals num2. [code] #include … | |
Re: >sort a Randomized Dynamic 2D Matrix of Integers That could be a problem, but first I'll describe how you would do it with a real array. >how Qsort will help me? You cheat and give qsort something that it can work with. >if a 2D array is one big 1D … | |
Re: >any builtin function in c++ that converts a decimal number into binary number?? Maybe, depending on what you want to do with it. If all you want is a string, then the bitset<> class is ideal: [code] #include <iostream> #include <bitset> #include <climits> int main() { int dec; std::cout<<"Enter a … | |
Re: >while (! my_file.eof()) That's wrong. The eof member function wasn't designed to be used as a loop condition. Change it to this: [code] while (my_file.getline(info,sizeof(info))) [/code] Aside from that, there's nothing wrong with your code. It works perfectly on three of my compilers. Trim the code down as much as … ![]() | |
Re: >Also, calling atof for a double maybe a bad idea - losing precision/etc Calling atof may indeed be a bad idea, but not for the reason you stated. atof returns a double, so the only loss of precision would come from the converted string not representing a value that a … | |
Re: >i still have the first problem of the program running continuously and never stopping. Where does it do this? Have you stepped through your program in a debugger to find out the loop that keeps repeating? There are only four places that this could happen: the two loops in getInput … | |
Re: "tell me", "give me"; you realize that a large portion of programming consists of solving problems? You've decided that you want to write a parser, and that's a good project. You want to write one for C, which is far more than a mini-project that should take less than 30 … | |
Re: Okay, let's make some observations on the goto code: [code] Y: A B if a GOTO X C if b GOTO Y X: D [/code] First, Y is always executed at least once because the test to GOTO Y is at the end of the "block". That suggests a loop … | |
Re: >Why not write a Python program to translate C++ code to Python code? Probably (barring sneaky tricks that wouldn't count) because you'd effectively be writing both a C++ and Python parser and evaluator, not to mention a kickass AI to convert C++ into intelligent Python. Doable, but very very difficult … | |
Re: >Does anybody know the limit of nested for loops in C or C++? 15 levels in C89, 127 levels in C99 and 256 in C++ are the minimum limits. Any decent compiler should take the standard's advice and not impose arbitrary limits, so if you hit pretty much any implementation … | |
Re: >Can someone tell me why this happens Sure. Since you're working with a pointer to an array, you need to dereference the pointer [b]first[/b] before you start trying to index the array. When you say *myarray[i][j], you're doing the indirection in the wrong order, with [i][j] first, then * because … | |
Re: When it comes to a beginner's book on C++, there's only one choice: Accelerated C++ by Andrew Koenig and Barbara Moo. No other book I've read comes close to the awesomeness of that one as a first book, and I've read pretty much every text on C++ that you're likely … | |
Re: >I'm not sure how I may move it to the other forum Done. In the future, you can either delete your thread with the thread tools provided nobody has posted a reply, or you can contact a moderator with admin powers on both the to and from forum (such as … | |
Re: >Is it really a good program? It's okay, but I wouldn't even consider replacing Photoshop with the GIMP. All of my professional graphic artist and digital photographer friends agree. In my opinion, the GIMP is for systems that don't support Photoshop, free software fanatics who don't care about usability and … | |
Re: That's pretty sappy, freesoft. Happy birthday, J, you're one year closer to dying of old age. ;) | |
Re: >I must have a bad version of Microsofts C++ compiler. Yea, that's it exactly. :rolleyes: :rolleyes: :rolleyes: >Does that work? No, it doesn't. Casting a floating-point value to an integral value truncates rather than rounds. The precision will be lopped off, leaving the whole value unchanged. This works though: [code] … | |
Re: There's no standard way (C and C++ are line oriented), so you'll need to tell us your compiler and operating system. | |
Re: >Any recommendations? A damp cloth doesn't work for you? Stop touching your screen or wash your hands more often. :rolleyes: | |
Re: >I would like to know which is better. There's no difference if they both compile (they might not for user-defined types), pick which you find more intuitive. >Real C++ people...? I don't think I count as a real C++ person, but both call the primary (non-copy) constructor. The only noticeable … | |
Re: [url]http://www.eternallyconfuzzled.com/tuts/sorting.html[/url] | |
Re: >getline() is a method of std::string class and (I think) iostream. It depends on which getline you're talking about, but taken as a whole, your statement is incorrect across the board. You're mixing up the getline member function provided by std::istream (which uses C-style strings) and the getline function provided … | |
Re: Hmm, I would say sscanf would be your best bet for a quick solution: [code] char *compare_number(char *first_number,char *second_number) { char *result; int x, y; sscanf ( first_number, "%d", &x ); sscanf ( second_number, "%d", &y ); return x < y ? first_number : second_number; } [/code] Naturally, you'll need … | |
Re: The first function call is the root, then any recursive call is a child of the root. Repeat for each child. | |
Re: >I'd hate to see you give a link to heavy The C++ standard would probably be categorized as heavy reading, so would any volume of Knuth. | |
Re: [code] for (iter = scores.begin(); iter != scores.end(); ++iter) ++(*iter); [/code] Parens are there because a [b]lot[/b] of people have trouble with the associativity of operators that have equal precedence. It's right to left in this case, so you can safely remove the parens if you want and the dereference … | |
Re: Something like this? [code] #include <stdio.h> #include <wchar.h> #define UNICODE(x) L#x int main ( void ) { wchar_t *p = UNICODE ( xyz\n ); fputws ( p, stdout ); return 0; } [/code] By the way, Unicode is only an encoding, not a storage specification. The actual storage is with … | |
Re: [QUOTE=winbatch]Have a text file with 2 columns. Load the columns into a map<string,string> . Pick a random word from the map by using a function like srand() (keeping in mind that the number must be below the .size() of the map. if the answer they provide equals the value in … | |
Re: [QUOTE=dkotyhh]:mrgreen: :mrgreen: :mrgreen: :cool:[/QUOTE] If you're going to do a necropost, at least make it meaningful. :mad: | |
Re: >please post the way of calling Please read a book, or stop using libraries and features that are so far beyond you. cust is a vector of pointers to customer. You're trying to use a member function of the customer class as if it were a member function of the … | |
Re: >The alternatives I've thought of are as follows, but they all seem inefficient They [b]seem[/b] inefficient, or they [b]are[/b] inefficient? Chances are good that there's no performance issue and your time is better spent elsewhere. |
The End.