delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/19/18:16:50

From: Dave Pearson <davep AT hagbard DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Problem with the string data format!
Date: Mon, 19 May 1997 16:42:06 GMT
Organization: Hagbard's World (A Private Internet Host)
Sender: usenet AT hagbard DOT demon DOT co DOT uk
Message-ID: <slrn5o10mt.hdj.davep@hagbard.demon.co.uk>
References: <01bc643c$9a240b00$d541b7c2 AT engineering5 DOT engineering DOT it> <5lppiq$dv9 AT news DOT ox DOT ac DOT uk>
Lines: 57
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019