Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

strings in c++

Status
Not open for further replies.

kenjisamurai

Programmer
Mar 14, 2002
4
0
0
US
Ok I am a beginner in C++ and I have one problem that is halting my learning. I have #include <string> already on, but I can't use string identifier at all. something like:

string stupid1, stupid2;

gives me errors on that particular line. What's up with this?
 
using namespace std ;
try to put this line in your code and it should work !

#include <string>
using namespace std ;
....
...
string stupid1, stupid2;
 
Actually, the header file is not <string>. . but rather <string.h>

try that and see if it'd work.

C-Fresh
 
Actually, <string.h> is for C string functions; <string> is the correct header file (i.e. you're already using the right one).
 
<string> and <string.h> are two different libraries.

<string> contains what you need to use string variables.

<string.h> contains functions that work on character arrays. (like strcat, strcpy, and strlen to name a few)

I personally prefer using character arrays when possible, they work a lot better. If I need to do a lot of parsing of strings, use CString. (I believe it is in <afxdisp.h>)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top