166 Posted Topics

Member Avatar for moonL!ght
Member Avatar for chiwawa10
0
132
Member Avatar for martin_anastaso

You didn't post any code snippets, but it seems like you're reading or inputting uninitialized data.

Member Avatar for martin_anastaso
0
1K
Member Avatar for sanjuanair

[CODE] switch( var ) { case 1: // ; break; default: std::cout << "Default." << std::endl; break; } [/CODE] Any case except the integer 1 will output "Default.", as it is the default statement. I cannot think of a different context for this question, if it's something else you'll need …

Member Avatar for Narue
0
125
Member Avatar for BLUEC0RE

It may be worthwhile to note that scanf ignores blank input, newline, and tab. (in the context you are using it) What I mean by this, is that blank input is still input, not EOF.

Member Avatar for gerard4143
0
3K
Member Avatar for hq1

[CODE] int gcd(int a, int b){ if (b==0) return a; #ifdef DEBUG printf("gcd(%d, %d)= ", b,a%b); #endif gcd(b, a%b); // where did you calculate which number was smaller? // is a%b really what you wanted here? } [/CODE]

Member Avatar for Unimportant
0
114
Member Avatar for #include<>
Member Avatar for sterlingf5890

[CODE] using namespace std; // It's better if you don't pollute your global namespace string str; // Why not declare this in main()? string stri; int inputString (int n); // Not sure I understand why you pass an int here bool palindromeTest (bool isPalindrome); // why do you pass this …

Member Avatar for Unimportant
0
139
Member Avatar for Mabalo

To read from a file, you might try using std::ifstream If each item is on it's own line, one method you may try, would be storing each line as a std::string, and place them in an array of std::string. Then use your rand() variables to select an array offset (such …

Member Avatar for Unimportant
0
114
Member Avatar for subkin13

Might I inquire why this would be necessary, as your return type cannot change? Perhaps what you actually wanted was a template, I am not certain. [CODE] template <typename T> T* foo( T t ) {return &T;} [/CODE] In the code you have above, you may as well just use …

Member Avatar for subkin13
0
197
Member Avatar for lashatt2

You likely got the endianness wrong for reading data (as opposed to network endianness), but base 2 is how data is represented to a processor.

Member Avatar for Unimportant
0
68
Member Avatar for invisi

Invisi, nArray is passed as a function parameter. What you are doing is making another array, using memcpy to move the contents of the old array to the new one, and then deleting the old one. You return a pointer (address of 0th element of array) to the new array …

Member Avatar for Greywolf333
0
116
Member Avatar for ekailan

Do you know how much memory will be allocated during run time? For example, if you are resizing an array dynamically, based on packet input, the array could be a size much larger than it was at the time the program started. If you are not using any dynamic memory, …

Member Avatar for Unimportant
0
238
Member Avatar for manalibhadula

If you mean you want no intermediate data, you may want to sort during the merge. Before I continue I'd like to point out that you aren't actually merging your arrays, in the code you posted. You're overwriting one. You're also incrementing i twice. [B]Edit: I actually have no idea …

Member Avatar for Unimportant
0
157
Member Avatar for Christ1m

[CODE] class Collection; // <-- pointers to Category class Category; // <-- pointers to array dvd[] and std::string description/name struct dvd_info { category* cat; std::string title; int year; double time, price; // <-- time in seconds, use a formatting function dvd_info() : cat(NULL), title("\0") { } dvd_info( cat *c, std::string …

Member Avatar for Unimportant
0
212
Member Avatar for yesamin

Please use code tags. This is your problem: [CODE] for (int i=0; i<5; i--) // you are decrementing i, it will become -1 { int times =5; // times will always be five [/CODE] Is this really what you want to do? [CODE] else if (guess > secret_number)&&(times == i--) …

Member Avatar for Unimportant
0
2K
Member Avatar for jogieglenmait

[CODE] std::stringstream ss; ss << "A line of text." std::ofstream file("lines.txt", std::ios::out | std::ios::app); if(file.is_open()) file << ss.str() << '\n'; file.close(); [/CODE] [B]Edit:[/B] Couple notes You may want to read about ofstream flags, they are non-trivial. Closing the file is important. You don't need to use a stringstream like I …

Member Avatar for jogieglenmait
0
127

The End.