• C++ error
    6 replies, posted
[quote]#include <iostream> int main() { int iAge; int iAge2; std::cout << "Hello." << std::endl; std::cout << "How old are you?" << std::endl; std::cin >> iAge; std::cout << "You are " << iAge << " years old." << std::endl; std::cout << "Is that true?" << std::end1; std::cin >> iAge2; std::cout << "You are " << iAge2 << " years old, that is more like it. " << std::endl; return 0; } [/quote] Before hand, i started with just the Hello thing and it ended properly and worked all good. Then i found out how to use integers and inputs so i did this. It dosnt work D: Why not D:
Rated dumb because you didn't tell us what doesn't work and what compile errors you got. Although I can tell you that you wrote count instead of cout. If you read the errors, you'd have known that. [editline]09:21PM[/editline] Oh and end1 instead of endl
This is what happens now when i try to debug it after fixing count and end1 [quote]1>------ Build started: Project: test3, Configuration: Debug Win32 ------ 1>Compiling... 1>main.cpp 1>c:\documents and settings\shane salerno\my documents\visual studio 2008\projects\test3\test3\main.cpp(10) : error C2039: 'end1' : is not a member of 'std' 1>c:\documents and settings\shane salerno\my documents\visual studio 2008\projects\test3\test3\main.cpp(10) : error C2065: 'end1' : undeclared identifier 1>Build log was saved at "file://c:\Documents and Settings\Shane Salerno\My Documents\Visual Studio 2008\Projects\test3\test3\Debug\BuildLog.htm" 1>test3 - 2 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== [/quote] Also what happens, a cmd black box thing opens saying Hello World! and when i hit a key to continue it closes.
[code]#include <iostream> int main() { int iAge; int iAge2; std::cout << "Hello." << std::endl; std::cout << "How old are you?" << std::endl; std::cin >> iAge; std::cout << "You are " << iAge << " years old." << std::endl; std::cout << "Is that true?" << std::endl; std::cin >> iAge2; std::cout << "You are " << iAge2 << " years old, that is more like it. " << std::endl; return 0; }[/code] Not tested but it should work. Seriously though check your spelling next time.
[QUOTE=HoliestCow;17499681]This is what happens now when i try to debug it after fixing count and end1 Also what happens, a cmd black box thing opens saying Hello World! and when i hit a key to continue it closes.[/QUOTE] it's end el not end one. std::endl;
[QUOTE=Wickedgenius;17499733][code]#include <iostream> int main() { int iAge; int iAge2; std::cout << "Hello." << std::endl; std::cout << "How old are you?" << std::endl; std::cin >> iAge; std::cout << "You are " << iAge << " years old." << std::endl; std::cout << "Is that true?" << std::endl; std::cin >> iAge2; std::cout << "You are " << iAge2 << " years old, that is more like it. " << std::endl; return 0; }[/code] Not tested but it should work. Seriously though check your spelling next time.[/QUOTE] Tested it on G++ and it worked. It prints: [QUOTE] sysadmin@sysadmin-desktop:~$ ./a.out Hello. How old are you? 99 You are 99 years old. Is that true? y You are -1076759480 years old, that is more like it. sysadmin@sysadmin-desktop:~$ [/QUOTE] What's up with the numbers?
[QUOTE=Eudoxia;17505288]Tested it on G++ and it worked. It prints: What's up with the numbers?[/QUOTE] It's asking a yes/no question when the variable type is an int.
Sorry, you need to Log In to post a reply to this thread.