Mail Archives: djgpp/1997/05/19/18:16:50
On 19 May 1997 14:54:18 GMT, George Foot <mert0407 AT sable DOT ox DOT ac DOT uk> wrote:
> Lorenzo Soncini (lsoncini AT mbox DOT linknet DOT it) wrote:
> : How can I use the string data type with DJGpp ?
>
> C doesn't have a string data type; a string is viewed as an array of
> chars. For example:
>
> char my_string[80];
>
> Then my_string could hold up to 79 characters, plus one '\0' to mark
> the end of the string.
Looking at what the poster was asking and the code he included I don't
think he is asking about C but about C++. His mistake, as far as I
can see, is that he is including <string.h> when he should really
be including <string> (note no .h).
In the case of his example, he probably wants something more along
the lines of:
-- foo.cpp -----------------------------------------------------------
#include <iostream.h>
#include <string>
int main( void )
{
string s;
s = "Hello, World!";
cout << s << endl;
s += "\nLook ma! No strcat()!";
cout << s << endl;
return( 0 );
}
----------------------------------------------------------------------
and then he needs to compile with:
gxx foo.cpp -o foo
> You should get a book on C programming to learn about this; it is a
> big topic and shouldn't really be on this mailing list/newsgroup.
Considering the fact that he appears to be asking about C++ that's a
little unfair. :-)
--
Take a look in Hagbard's World: | w3ng - The WWW Norton Guide reader.
http://www.acemake.com/hagbard/ | ng2html - The NG to HTML converter.
Also available in the UK: | eg - Norton Guide reader for Linux.
http://www.hagbard.demon.co.uk/ | dgscan - DGROUP scanner for Clipper.
- Raw text -