Unable to run Visual C++, please help :-)
Hi,
I just install visual C++ 2008 on my desktop from microsoft website for free. However, when I run my simple program , it shows some error :
my program is :
#include<iostream>
#include<stdlib.h>
using namespace std ;
main()
{
cout << " Hello World! " ;
system('pause') ;
return 0;
}
The error is :
1>------ Build started: Project: testing 1, Configuration: Debug Win32 ------
1>Compiling...
1>test new 1.cpp
1>c:\documents and settings\kf.choong\my documents\visual studio 2008\projects\testing 1\testing 1\test new 1.cpp(6) :
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\kf.choong\my documents\visual studio 2008\projects\testing 1\testing 1\test new 1.cpp(9) :
error C2015: too many characters in constant
1>Build log was saved at "file://c:\Documents and Settings\kf.choong\My Documents\Visual Studio 2008\Projects\testing 1\testing 1\Debug\BuildLog.htm"
1>testing 1 - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Please help. this is a suimple program and it should be able to run.
Thank you and your effort is very much appreciated :-)
Best Regards,
KF
Quote:Original post by KF
Hi,
I just install visual C++ 2008 on my desktop from microsoft website for free. However, when I run my simple program , it shows some error :
my program is :
#include<iostream>
#include<stdlib.h>
using namespace std ;
main()
{
cout << " Hello World! " ;
system('pause') ;
return 0;
}
There is nothing wrong with your installation. Your "simple program" is not valid C++.
In C++, return types for functions must be explicitly stated; thus, 'int main()' (since in C++, main() must return int).
Also, single quotes are for single-character constants; for string constants (like the text "pause"), you require double quotes.
You don't need to include stdlib.h either (and in C++, it should be cstdlib anyway), but that won't cause the compiler to complain - it's just messy.
Quote:Original post by KFThere are two errors which is stopping that program from compiling. The first is you haven't specified a return type for "main" and - as the error message says - C++ does not support default-int. The second problem is that 'pause' (with single quotes) is not a valid string. Single quotes are used to enclose a single character constant, double quotes are used for string.
Please help. this is a suimple program and it should be able to run.
The following code should compile:
#include<iostream>#include<stdlib.h>using namespace std ;int main(){cout << " Hello World! " ;system("pause") ;return 0;}
Edit: too slow!
Hi Codeka and Zahlman,
Many thanks for oyur advice.
I am sorry that I do not notice this simple mistakes. The program now can run after I have changed it. I should have learn how to read the error message. it is quite hard for me to understand it as there is no indication on which line is actually causing the problem. Anyway, thank you for your help. you have a pleasant day :-)
Thank you both of you.
Best Regards,
KF
Many thanks for oyur advice.
I am sorry that I do not notice this simple mistakes. The program now can run after I have changed it. I should have learn how to read the error message. it is quite hard for me to understand it as there is no indication on which line is actually causing the problem. Anyway, thank you for your help. you have a pleasant day :-)
Thank you both of you.
Best Regards,
KF
Actually, the line numbers are given in the round brackets following the file name:
1>c:\documents and settings\kf.choong\my documents\visual studio 2008\projects\testing 1\testing 1\test new 1.cpp(6) :
In this case line number 6.
You can also doubleclick onto the error message in the output window to automatically jump to the offending line.
1>c:\documents and settings\kf.choong\my documents\visual studio 2008\projects\testing 1\testing 1\test new 1.cpp(6) :
In this case line number 6.
You can also doubleclick onto the error message in the output window to automatically jump to the offending line.
Quote:Original post by KF
there is no indication on which line is actually causing the problem
Yes there is, check out the "6" and "9" on the end of the error message lines.
Also, in VC++ you can double-click the error rows to go to the corresponding source point (if available) automatically.
EDIT: too slow!
Hi Endurion and Nik02,
Many thanks for your advice.
It had made my debug process easier. :-)
Thank you guys. You all are so helpful.
Best Regards,
Choong
Many thanks for your advice.
It had made my debug process easier. :-)
Thank you guys. You all are so helpful.
Best Regards,
Choong
Hi Endurion and Nik02,
Many thanks for your advice.
It had made my debug process easier. :-)
Thank you guys. You all are so helpful.
Best Regards,
KF
Many thanks for your advice.
It had made my debug process easier. :-)
Thank you guys. You all are so helpful.
Best Regards,
KF
Who on earth rated KF down? One of the most polite new posters I've ever seen on this website after looking at other threads. Rate++ to rectify. [smile]
Quote:Original post by AardvajkI agree, but I suppose it acts as incentive to post in the For Beginners forum if you're a beginner - otherwise certain things can come across to some as arrogance rather than naivety.
Who on earth rated KF down? One of the most polite new posters I've ever seen on this website after looking at other threads. Rate++ to rectify. [smile]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement