Visual C++ 2005 Home Edition
Hi all,
I am absolutely new to C++ so I downloaded Visual C++ 2005 Express Edition. And all of the tutorials I have found on the internet do not have the same GUI as this C++ edition, so I was wondering if I downloaded the right C++? I also tried running code snippets from the tutorials and it will give me build errors. I tried
Code:
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
cout<<"Hello World\n";
}
Re: Visual C++ 2005 Home Edition
To use cout you need to include the iostream header, which contains those functions. cout lives in the std namespace so you can either use std::cout or import the namespace.
Code:
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
}
Or
Code:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!\n";
}
Note that instead of \n you can use std::endl (end line) which is a stream manipulator, as follows:
Code:
std::cout << "Hello World!" << std::endl;
Re: Visual C++ 2005 Home Edition
And make sure you select "Empty Project" in the project wizard, or you'll get weird errors.
Re: Visual C++ 2005 Home Edition
Ok, so when I try to run the below code in an empty project it will say
"Unable to start program 'C:Learning Project.exe'
The system cannot find the specified file
Code:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!\n";
}
Now remember, I am completely new to C++ so I don't know whats goin on :D
Re: Visual C++ 2005 Home Edition
I'd say you have some project configuration problems. It's attempting to launch a file that most definitely doesn't exist. Can't remotely solve that, though. Sorry.
Re: Visual C++ 2005 Home Edition
What is everything I need to run the program.. a header file, .ccp?
Re: Visual C++ 2005 Home Edition
Dont even need a header file. If you start with an empty project there should be nothing. Just add one .cpp source file, dump that code in, hit build and run. If that doesn't work, you definetely have some weird issue. try building it to different locations, see if that makes any difference.
Re: Visual C++ 2005 Home Edition
When I try to build, it says 0 succeeded and 1 up-to-date... but when i click on "start debugging" then it says the same error :confused:
Re: Visual C++ 2005 Home Edition
Try this:
New project.. Win32 Console App
The wizard comes up, click Application settings...
Check Empty Project..
Check Finish
Go to the solution explorer on the right..
Right click on Code.. Add.. New Item
Pick C++ File (.cpp) from the code section of the tree. Call it whatever you want (main.cpp is usually appropriate)
Then, you can start using some of the examples posted above.
P.S. - For learning and whatnot, if you're running it in the IDE, It's often helpful to add the line system("pause"); to the end of the program, so it doesn't flash on screen then go away.
Bill
Re: Visual C++ 2005 Home Edition
I think that you should leave in:
#include "stdafx.h"
then type:
#include <iostream>
int main()
{
cout << "Hello World!";
return 0;
}
I think that the line "#include "stdafx.h" has something to do with including essential files necessary to code in the VC++ environment. Try that and let me know what happens.
Re: Visual C++ 2005 Home Edition
Wrong. There are no "essential files necessary to code in the VC++ environment".
It's a project setting that Empty Project avoids that makes stdafx.h necessary. Which is why I always tell people to create empty projects.
Re: Visual C++ 2005 Home Edition
Quote:
And all of the tutorials I have found on the internet do not have the same GUI as this C++ edition, so I was wondering if I downloaded the right C++?
The best comparison of the major VS 2005 editions can be found at this locations: http://msdn2.microsoft.com/en-us/library/hs24szh9.aspx
Re: Visual C++ 2005 Home Edition
What type of C++ are you trying to put in to the 2005 compiler? I'm sure that 2005 is based around .NET. Are you using VC++ 6 or ANSI C++ at all?
i also thought i saw a hello world above. have you tried using these examples
VC++6
//Hello World Example
#include<iostream.h>
using namespacestd;
int main()
{
cout<<"Hello World!" << endl;
return 0;
}
VC++.NET
#include "stdafx.h"
#using <mscorlib.dll>
#include <tchar.h>
using namespace system;
int_tmai(void)
{
Console::Writeline(S"hello world!");
return 0;
}