www.digitalmars.com         C & C++   DMDScript  

c++ - Am I missing something? There seems to be no "string" class?

reply Paul M. <pgm92103 yahoo.com> writes:
There seems to be no "string" class?  The <string.h> file has the 
normal str***() functions.  But there seems to be no string class?

hw.cpp(16) : Error: undefined identifier 'string'
         string str("test");

It seems to do iostream stuff poorly.

This has been my "go to" compiler for plain C code.  But this 
sucks.
Feb 06 2018
parent =?UTF-8?B?TWFub8OrbA==?= <dmcforul godzil.net> writes:
On Tuesday, 6 February 2018 at 19:29:02 UTC, Paul M. wrote:
 There seems to be no "string" class?  The <string.h> file has 
 the normal str***() functions.  But there seems to be no string 
 class?

 hw.cpp(16) : Error: undefined identifier 'string'
         string str("test");

 It seems to do iostream stuff poorly.

 This has been my "go to" compiler for plain C code.  But this 
 sucks.
Hi Paul, I sense a couple confusions here, are you trying to make C or C++ code? They not really are the same thing even if really close. C have the <string.h> header, but there is no string type in C, the standard way of handling string in C is to use array of bytes as in char *str = “Hello World”; C++ on the other hand does not normally use the string.h file, and works either with the same type of array as for C, but also have its own string type which is std::string which is define in <string> (with no .h) More information about the C++ class: http://www.cplusplus.com/reference/string/string/ I don’t know if DMC++ provide that header file, I’m not sure from which version of the C++ it come from. (And there is no class in C) Hope that will help. Manoel
May 25 2018