string.h included, string still undefined

Working on a project for school, need to use a couple string variables in the project but cannot get them recognized. I have #include <string.h> and also tried #include <string>, both valid header files(files exist and load) but string type remains undefined.

I am using Visual C++ 2010 Express.


Thanks for any hints.
closed account (zb0S216C)
It's #include <string>. C++ style headers don't have extensions, and C-converted headers are prefixed with C, such as #include <cmath>.

Wazzak
Last edited on
#include <string> doesn't work either.

Here is a test program with string not working:





// string test.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <string>


int _tmain(int argc, _TCHAR* argv[])
{
string teststr;
return 0;

}


build log:

------ Build started: Project: string test, Configuration: Debug Win32 ------
stdafx.cpp
string test.cpp
\\vmware-host\shared folders\documents\visual studio 2010\projects\string test\string test\string test.cpp(10): error C2065: 'string' : undeclared identifier
\\vmware-host\shared folders\documents\visual studio 2010\projects\string test\string test\string test.cpp(10): error C2146: syntax error : missing ';' before identifier 'sth'
\\vmware-host\shared folders\documents\visual studio 2010\projects\string test\string test\string test.cpp(10): error C2065: 'sth' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
closed account (zb0S216C)
Qualify string with std::. For example: std::string. Optionally, after the preporcessor directives, and before main( ), write using namespace std;.

Wazzak
That did the trick, thank you.
Topic archived. No new replies allowed.