English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have included ,but the program does not recognize
string x;
I can't understand why

2007-01-20 19:56:29 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

3 answers

You might have to provide us with a little more info for anyone to really give specific help. I can only guess that you are using C++, but you might be using C.

If you are using C, then you cannot declare string x, C works on arrays of characters, not really strings like C++ does, the string library under C has member functions that will let you manipulate arrays, but you declare it more like " char x[4]; "

In C++ try leaving off the period h, and just use for your include. Depending on your compiler you might also have to change to "string", as some compilers do not recognize the string library as a standard library and will have to look for it in a different directory than where C++ puts the standard libraries. In Visual Studio this is what you will have to do. Or you will have to set the environment up to include the path for the directory of the string library location.

Also, in C++ you might have to use an using command, like " using std::string; ", otherwise every time you use the string command you will have to fully qualify your command, like this, " std::string s1 ", which by the way is the preferred standard to use.

Try looking at this website, it has a ton of stuff on the libraries and what all the different member functions do and how to use them.

http://www.cppreference.com/

2007-01-20 20:27:50 · answer #1 · answered by Anonymous · 0 0

Insure you're compiling in C++ mode. The default is often C, and C does not recognize the type "string" unless you define it somewhere, and you haven't.

See your manual about "compiler switches" or "settings." I'll bet big money that's the issue here.

2007-01-21 17:21:59 · answer #2 · answered by gene_frequency 7 · 0 0

try using "CString x;" (if using C++)

2007-01-21 09:02:50 · answer #3 · answered by justme 7 · 1 0

fedest.com, questions and answers