Whats wrong with my code?


#include <iostream>
using namespace std;

int main ()
{
cout << "Hello World!";
return 0;
}

I keep on getting two errors:

"there were build errors. Would you like to continue and run the last succesful build?"

And

"Unable to start program. The system cannot find the filed specified."

I've already installed visual studio express twice. But it just keeps on giving me the same error
Make sure you started a new Blank Project and not a new Console Project. From there you have to right click on the Source Files folder in your solution and add a new cpp file, eg Main.cpp
Last edited on
what are the errors?

go to view->other windows->error list and post what you see there.
1
2
3
4
5
6
7
8
9
#include <iostream>
using namespace std;

//int main ()
int main() //drop the space, maybe...
{
  cout << "Hello World!";
  return 0;
}
you should use DEV C++ compiler ... it is available at brothersoft.com
Dev-Cpp isn't a compiler, it is an IDE. It comes with an ancient compiler and is never updated, don't use it!
http://www.cplusplus.com/forum/articles/36896/
If you use Microsoft Visual Studio 20## , you must include iostream with " .h "
like this
#include <iostream.h>

some compilers can accept <iostream>

and one thing , if you want to compile your codes faster, when you want to use the Syntax "using namespace std(any classes) ;" just at the end of work see again your code and everything that your code need like "cin , cout , endl " 1 on 1 , type

using namespace class-name ; --> using class-name::object-name ;

using std::cin ;
using std::cout ;
using std::endl ;

in the Data Structure (and if you're a computer sciences student), Complexity of Time is so important for your code!

If you use Microsoft Visual Studio 20## , you must include iostream with " .h "
like this
#include <iostream.h>

Are you sure?
Actually you dont have to do <iostream.h> with VB.

(Using VB Express 2010);

You should (I know you should not use this, but just to see) use system("pause"); right after cout <<.

Should look like
1
2
3
4
5
6
7
8
9
10
#include <iostream>
using namespace std;

int main (){

cout << "Hello World!";
system("pause");

return 0;
}
Proof of not using the .h (Just made this)

http://imageshack.us/photo/my-images/12/capturetbu.jpg

Good luck!
Don't use

system("pause")

Instead use

1
2
3
cin.get();

std::cin.get();
Topic archived. No new replies allowed.