2

When i try to compile the following code:

#include <string.h>
using namespace std;
typedef std::basic_string<char> foostring;
foostring foo = "foo";

I get the following error:

stringtest.cpp:5: error: expected initializer before ‘<’ token
stringtest.cpp:6: error: ‘foostring’ does not name a type

My compiler is: g++ (Ubuntu 4.4.1-4ubuntu9) 4.4.1
What am i doing wrong? i intend to use this with windows TCHAR for unicode support once i figure out how to use it.

1 Answer 1

5

The header is <string>, not <string.h>.

None of the standard library headers end with an extension. (You're including the C header string.h, which should be included in C++ via <cstring>, had that been what you actually wanted.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.