Posted December 7, 200618 yr invalid operands of types `<unknown type>' and `int' to binary `operator<<' and i have this in the program. //Simple Adding #include <iostream> using namespace std; int main () { int a; int b; int c; int d; int result; a = a + d - c + b; b = 13; c = 15; d = 225; result = a + 2; count << result; return 0; } this is the part that gets high lighted and is what the error is directed to count << result; i do not under stand this error can you help?
December 7, 200618 yr invalid operands of types `<unknown type>' and `int' to binary `operator<<' and i have this in the program. //Simple Adding #include <iostream> using namespace std; int main () { int a; int b; int c; int d; int result; a = a + d - c + b; b = 13; c = 15; d = 225; result = a + 2; cou[u]n[/u]t << result; return 0; } this is the part that gets high lighted and is what the error is directed to cou[u]n[/u]t << result; i do not under stand this error can you help? it's cout not count secondly your addition is going to give you funny answers ;)
December 8, 200618 yr Author oh yeha im a dumbass! :facesj: how would i have the window stay open long enough for me to read the number?
December 8, 200618 yr A simple solution to get it to pause after running it is: cin.get(); getch(); system ( "pause" ); GetAsyncKeyState ( VK_END ); etc.
December 8, 200618 yr Don't use system pause, wait for input cout << result << "\n"; cout << "Exit? y/n\n"; cin >> wait; { if (wait == "yes"); return 0; } } #include <iostream> using namespace std; int main () { int a; int b; int c; int d; int result; string wait; a = a + d - c + b; b = 13; c = 15; d = 225; result = a + 2; cout << result << "\n"; cout << "Goodbye\n"; cin >> wait; } I haven't done c++ for ages but it should be all good :D
December 9, 200618 yr Author just to correct you... if you put /n in " " then it would say /n and it wouldnt make a new line. but if you put /n it would make a new line. again i know you havent in ages but it neede corrected :)
December 9, 200618 yr Don't use system pause, wait for input cout << result << "\n"; cout << "Exit? y/n\n"; cin >> wait; { if (wait == "yes"); return 0; } } #include <iostream> using namespace std; int main () { int a; int b; int c; int d; int result; string wait; a = a + d - c + b; b = 13; c = 15; d = 225; result = a + 2; cout << result << "\n"; cout << "Exit? y/n\n"; cin >> wait; { if (wait == "yes"); return 0; } } I haven't done c++ for ages but it should be all good :D lewl... I can tell you never did get far into C++. Because system ( "pause" ); delays execution until a key press is detected. Using STL is great in applications but adds unnecessary bloat to the project size and is slower than regular C code. for example... char *szStr = ( char* )malloc ( 32 ); // you could use STL, but C code is faster and is smaller. scanf ( "%s", &szStr ); if ( !stricmp ( szStr, "yes" ) ) { free ( szStr ); return 0; }
December 9, 200618 yr http://www.gidnetwork.com/b-61.html * It's not portable. This works only on systems that have the PAUSE command at the system level, like DOS or Windows. But not Linux and most others... * It's a very expensive and resource heavy function call. It's like using a bulldozer to open your front door. It works, but the key is cleaner, easier, cheaper. What system() does is o suspend your program o call the operating system o open an operating system shell (relaunches the O/S in a sub-process) o the O/S must now find the PAUSE command o allocate the memory to execute the command o execute the command and wait for a keystroke o deallocate the memory o exit the OS o resume your program There are much cleaner ways included in the language itself that make all this unnessesary. * You must include a header you probably don't need: stdlib.h or cstdlib
December 10, 200618 yr http://www.gidnetwork.com/b-61.html does it really matter for a small application? If your that concerned with memory usage you should be coding in C and Assembly.