When I run the following code it works in eclipse and netbeans but not in visual C++. Is there something I'm missing? It keep saying I'm missing parts of code "semi-colons, parenthesis, etc.) but I'm not. Here's the code:
ok so I still have errors and I created an empty project and added a new .cpp file called main and here's the new code. Is there something wrong still?
still nothing :( this appears on the output window:
c:\program files\microsoft visual studio 10.0\vc\include\ostream(487): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_streambuf<_Elem,_Traits> *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> while trying to match the argument list '(std::ostream, std::string)'
I get the following errors. Although the prompt does come up and it works:
'plz.exe': Loaded 'C:\Documents and Settings\Steven\My Documents\Visual Studio 2010\Projects\plz\Debug\plz.exe', Symbols loaded.
'plz.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', Cannot find or open the PDB file
'plz.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', Cannot find or open the PDB file
'plz.exe': Loaded 'C:\WINDOWS\system32\msvcp100d.dll', Symbols loaded.
'plz.exe': Loaded 'C:\WINDOWS\system32\msvcr100d.dll', Symbols loaded.
'plz.exe': Loaded 'C:\WINDOWS\system32\apphelp.dll', Cannot find or open the PDB file
'plz.exe': Loaded 'C:\WINDOWS\system32\version.dll', Cannot find or open the PDB file
'plz.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', Cannot find or open the PDB file
'plz.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', Cannot find or open the PDB file
'plz.exe': Loaded 'C:\WINDOWS\system32\secur32.dll', Cannot find or open the PDB file
The program '[4104] plz.exe: Native' has exited with code 0 (0x0).
Those aren't errors, only warnings. Those appear if you didn't build your exe with debug information. You can ignore them, unless of course you want to debug/step through your code.
In terms of the errors, it looks like you simply forgot to #include <string> in your code.
also.. Maybe it was something i didn't do when i installed VS. I have dual boot with mac and windows and I had to install mingw so maybe that's the problem? Does everyone usually have to go through all this too? I know in mac I didn't have to install anything else with eclipse or netbeans.. just ran the program and everything started fine.
Well.. I'm not sure what happened.. but I made a similar program from scratch and there were no errors. Is there a difference that could've made errors?
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
string name,choice;
cout << "Enter your name and press ENTER" << endl;
cin >> name;
cout << "Your name is " << name << "? (ENTER Yes or No)" << endl;
cin >> choice;
if (choice == "y"||"Y"||"Yes"||"yes")
cout << "Really? You really need a name change!" << endl;
else
cout << "Good! I was worried for a second there!" << endl;
system("pause");
return 0;
}
another thing. The "if" section is a bit off. I'm trying to write that if either y, Y, Yes, or yes is entered then it outputs the following statement.. but it seems like even if you put a random letter it outputs the first statement. is the "||" the right syntax for that?