I need help...desperately!

Started by
36 comments, last by theOcelot 15 years, 8 months ago
when you created your project, did you pick a console app or a win32 app?

try just starting a new project, make sure its a console app

and simpley use:
int main(){    return 0;}
[ dev journal ]
[ current projects' videos ]
[ Zolo Project ]
I'm not mean, I just like to get to the point.
Advertisement
Quote:Original post by sneaky_squirrel
I did what you said and got the following:

------ Build started: Project: Hi, Configuration: Debug Win32 ------
Compiling...
Hi.cpp
c:\documents and settings\compaq_administrator\my documents\visual studio 2008\projects\hi\hi\hi.cpp(3) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
Build log was saved at "file://c:\Documents and Settings\Compaq_Administrator\My Documents\Visual Studio 2008\Projects\Hi\Hi\Debug\BuildLog.htm"
Hi - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



Is there a file named 'stdafx.h' in your project? If not, make sure that you remove the line '#include "stdafx.h"' from your hi.cpp file. After which, you should recompile the project. I am guessing that you might not have this file in your project and are trying to include it in your source code.

try this aswell.

when starting a new project, in the wizard that pops up to select what kind of project, choose win32 console app, then on the next screen, make sure its an empty project.

I did just that, copy and pasted your code and it worked just fine, and you don't need to include stdafx.h, also I'd get rid of the "using std namespace, and use the namespace prefixs on the cout like so.

std::cout << "foobar" << endl
[ dev journal ]
[ current projects' videos ]
[ Zolo Project ]
I'm not mean, I just like to get to the point.
Ok but can you paste the code completely, I didn't get the replacing part ;D.
I Googled it and I found this;

In the Options go into Projects and Solutions -> VC++ Directories page and place this rows:

$(SystemRoot)\System32
$(SystemRoot)
$(SystemRoot)\System32\wbem

hope that helps its all I could find
I did as you told me to create the project/file.

I used the following code:

// my first program in C++

#include <iostream>

std::cout << "foobar" << endl;

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

And got this error message:

------ Build started: Project: Hello, Configuration: Debug Win32 ------
Compiling...
Hello.cpp
c:\documents and settings\compaq_administrator\my documents\visual studio 2008\projects\hello\hello\hello.cpp(5) : error C2143: syntax error : missing ';' before '<<'
c:\documents and settings\compaq_administrator\my documents\visual studio 2008\projects\hello\hello\hello.cpp(5) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\compaq_administrator\my documents\visual studio 2008\projects\hello\hello\hello.cpp(5) : error C2371: 'std::cout' : redefinition; different basic types
c:\program files\microsoft visual studio 9.0\vc\include\iostream(53) : see declaration of 'std::cout'
c:\documents and settings\compaq_administrator\my documents\visual studio 2008\projects\hello\hello\hello.cpp(9) : error C2065: 'cout' : undeclared identifier
Build log was saved at "file://c:\Documents and Settings\Compaq_Administrator\My Documents\Visual Studio 2008\Projects\Hello\Hello\Debug\BuildLog.htm"
Hello - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I Googled it and it said this:


In the Options go into Projects and Solutions -> VC++ Directories page and place this rows:

$(SystemRoot)\System32
$(SystemRoot)
$(SystemRoot)\System32\wbem

hope that helps its all I could find
I tried adding the directories and I got the following error message:

------ Build started: Project: Hello, Configuration: Debug Win32 ------
Compiling...
Hello.cpp
c:\documents and settings\compaq_administrator\my documents\visual studio 2008\projects\hello\hello\hello.cpp(5) : error C2143: syntax error : missing ';' before '<<'
c:\documents and settings\compaq_administrator\my documents\visual studio 2008\projects\hello\hello\hello.cpp(5) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\compaq_administrator\my documents\visual studio 2008\projects\hello\hello\hello.cpp(5) : error C2371: 'std::cout' : redefinition; different basic types
c:\program files\microsoft visual studio 9.0\vc\include\iostream(53) : see declaration of 'std::cout'
c:\documents and settings\compaq_administrator\my documents\visual studio 2008\projects\hello\hello\hello.cpp(9) : error C2065: 'cout' : undeclared identifier
Build log was saved at "file://c:\Documents and Settings\Compaq_Administrator\My Documents\Visual Studio 2008\Projects\Hello\Hello\Debug\BuildLog.htm"
Hello - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

If anyone understands any of this gibberish for making a simple program that inserts text I'd depreciate it.
You're getting all of that 'gibberish' because you're not allowed to write "std::cout << "foobar" << endl;" outside of a function.

Try:
// my first program in C++#include <iostream>int main (){  std::cout << "Hello World!";  return 0;}
SUCCESS

Also for the future, are these problems very common? That happen all the time and you have to spend 10 minutes figuring out, I find it very hard to understand these languages...very complicated, so can anyone guide me towards the next step?

This topic is closed to new replies.

Advertisement