Whats wrong with my code?

May 12, 2011 at 8:54pm

#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
May 12, 2011 at 8:56pm
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 May 12, 2011 at 8:57pm
May 12, 2011 at 9:40pm
what are the errors?

go to view->other windows->error list and post what you see there.
May 13, 2011 at 9:51am
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;
}
May 13, 2011 at 10:09am
you should use DEV C++ compiler ... it is available at brothersoft.com
May 13, 2011 at 10:30am
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/
May 13, 2011 at 11:23am
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!
May 13, 2011 at 11:43am

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

Are you sure?
May 14, 2011 at 4:47pm
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;
}
May 14, 2011 at 4:53pm
Proof of not using the .h (Just made this)

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

Good luck!
May 14, 2011 at 9:29pm
Don't use

system("pause")

Instead use

1
2
3
cin.get();

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