Page 1 of 1

Problem debugging hello world

Posted: Tue Oct 26, 2010 5:27 pm
by ShiunYean
When I tried to debug this code:

Code: Select all

#include <iostream>
using namespace std;
 
int main()
{
            cout << “Hello World!” << endl;
            return 0;
}
I get this:

Code: Select all

1>------ Build started: Project: testing, Configuration: Debug Win32 ------
1>  hello.cpp
1>c:\users\user\documents\visual studio 2010\projects\hello world\testing\hello.cpp(6): error C2065: '“Hello' : undeclared identifier
1>c:\users\user\documents\visual studio 2010\projects\hello world\testing\hello.cpp(6): error C2146: syntax error : missing ';' before identifier 'World'
1>c:\users\user\documents\visual studio 2010\projects\hello world\testing\hello.cpp(6): error C2065: 'World' : undeclared identifier
1>c:\users\user\documents\visual studio 2010\projects\hello world\testing\hello.cpp(6): error C2143: syntax error : missing ';' before '!'
1>c:\users\user\documents\visual studio 2010\projects\hello world\testing\hello.cpp(6): error C2065: '”' : undeclared identifier
1>c:\users\user\documents\visual studio 2010\projects\hello world\testing\hello.cpp(6): error C2563: mismatch in formal parameter list
1>c:\users\user\documents\visual studio 2010\projects\hello world\testing\hello.cpp(6): error C2568: '<<' : unable to resolve function overload
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(1021): could be 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1>          with
1>          [
1>              _Elem=unsigned short,
1>              _Traits=std::char_traits<unsigned short>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(1011): or       'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1>          with
1>          [
1>              _Elem=wchar_t,
1>              _Traits=std::char_traits<wchar_t>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(1003): or       'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>
1>          ]
1>          c:\program files\microsoft visual studio 10.0\vc\include\ostream(977): or       'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Can anyone help? I'm using Microsoft Visual Express C++ 2010.

Re: Problem debugging hello world

Posted: Tue Oct 26, 2010 6:44 pm
by happy125
nothing wrong with ur script. u run using f5 or ctrl f5. if u use ctrl f5 shuld be no prob

Re: Problem debugging hello world

Posted: Tue Oct 26, 2010 7:56 pm
by ShiunYean
happy125 wrote:nothing wrong with ur script. u run using f5 or ctrl f5. if u use ctrl f5 shuld be no prob
I tried pressing ctrl f5, still get the same error.

Edit:
I think I sort of fixed it, I tried a different code, this time i right click and choose compile and it worked, then I paste it to a folder, and used a command line to compile it.

Re: Problem debugging hello world

Posted: Tue Nov 02, 2010 3:59 pm
by Nerrazzuri

Code: Select all

#include <Windows.h>

Re: Problem debugging hello world

Posted: Wed Jun 15, 2011 7:43 pm
by wenwen123
er..i faced same prob wif him..bt i get this:

'rox.exe': Loaded 'C:\Users\user\Documents\Visual Studio 2010\Projects\rox\Debug\rox.exe', Symbols loaded.
'rox.exe': Loaded 'C:\Windows\System32\ntdll.dll', Cannot find or open the PDB file
'rox.exe': Loaded 'C:\Windows\System32\kernel32.dll', Cannot find or open the PDB file
'rox.exe': Loaded 'C:\Windows\System32\KernelBase.dll', Cannot find or open the PDB file
'rox.exe': Loaded 'C:\Windows\System32\msvcp100d.dll', Symbols loaded.
'rox.exe': Loaded 'C:\Windows\System32\msvcr100d.dll', Symbols loaded.
The program '[4372] rox.exe: Native' has exited with code 0 (0x0).

Re: Problem debugging hello world

Posted: Sat Jun 18, 2011 2:50 am
by Nerrazzuri
wenwen123 wrote:er..i faced same prob wif him..bt i get this:

'rox.exe': Loaded 'C:\Users\user\Documents\Visual Studio 2010\Projects\rox\Debug\rox.exe', Symbols loaded.
'rox.exe': Loaded 'C:\Windows\System32\ntdll.dll', Cannot find or open the PDB file
'rox.exe': Loaded 'C:\Windows\System32\kernel32.dll', Cannot find or open the PDB file
'rox.exe': Loaded 'C:\Windows\System32\KernelBase.dll', Cannot find or open the PDB file
'rox.exe': Loaded 'C:\Windows\System32\msvcp100d.dll', Symbols loaded.
'rox.exe': Loaded 'C:\Windows\System32\msvcr100d.dll', Symbols loaded.
The program '[4372] rox.exe: Native' has exited with code 0 (0x0).
There is nothing wrong with your codes, you're running the program fine with the PDB source, thats all. I believe you're getting the cmd to load and close too fast issue.

try adding

Code: Select all

system("PAUSE");
before the return 0; syntax.

Re: Problem debugging hello world

Posted: Sun Jun 19, 2011 8:50 pm
by happy125
Nerrazzuri wrote:
wenwen123 wrote:er..i faced same prob wif him..bt i get this:

'rox.exe': Loaded 'C:\Users\user\Documents\Visual Studio 2010\Projects\rox\Debug\rox.exe', Symbols loaded.
'rox.exe': Loaded 'C:\Windows\System32\ntdll.dll', Cannot find or open the PDB file
'rox.exe': Loaded 'C:\Windows\System32\kernel32.dll', Cannot find or open the PDB file
'rox.exe': Loaded 'C:\Windows\System32\KernelBase.dll', Cannot find or open the PDB file
'rox.exe': Loaded 'C:\Windows\System32\msvcp100d.dll', Symbols loaded.
'rox.exe': Loaded 'C:\Windows\System32\msvcr100d.dll', Symbols loaded.
The program '[4372] rox.exe: Native' has exited with code 0 (0x0).
There is nothing wrong with your codes, you're running the program fine with the PDB source, thats all. I believe you're getting the cmd to load and close too fast issue.

try adding

Code: Select all

system("PAUSE");
before the return 0; syntax.
and also

Code: Select all

#include cstdlib 
infront.

Re: Problem debugging hello world

Posted: Fri Jun 24, 2011 1:26 am
by wenwen123
thx all..which book is suitable for newbie??