delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/24/16:15:14

From: Martin Ambuhl <mambuhl AT earthlink DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Can someone compile this?
Date: Tue, 24 Nov 1998 15:42:02 -0500
References: <73cifb$gqm$1 AT clam DOT niwa DOT cri DOT nz> <19981124 DOT 12323889 AT eev6 DOT eev>
X-Posted-Path-Was: not-for-mail
X-Accept-Language: en
X-ELN-Date: 24 Nov 1998 20:42:50 GMT
X-ELN-Insert-Date: Tue Nov 24 12:45:17 1998
Organization: Nocturnal Aviation
Lines: 44
Mime-Version: 1.0
NNTP-Posting-Host: 1cust219.tnt11.nyc3.da.uu.net
Message-ID: <365B1A1A.771B6BAE@earthlink.net>
X-Mailer: Mozilla 4.5 [en] (Win95; I)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Michael Schuster wrote:
> 
> Hi everyone!
> 
> I'm desperately searching for a bug in my new 2.8.1 djgpp
> installation, but cannot find it.
> 
> The problem I face is the damn old String class problem which I posted
> already 2 times.
> As I want to know, if I do something wrong, I ask you if someone with
> a 2.8.1  can compile the following little c++ code (which I cnly can
> compile with my 2.7.xx djgpp?
> 
> #include <iostream.h>
> #include <string.h>
> #include <_String.h>
> 
> String xc="test2";
> char d[25]="dummy";
> 
> int main()
> {
>    xc=d;
>    strcpy(d,xc);
>    cout<<d;
> }

Note that the following will work and may be what you want:

#include <iostream>
#include <string>

string xc = "test2";
char d[25] = "dummy";

int main()
{
    xc = d;
    strcpy(d, xc.c_str());
    cout << d << endl;
}

Martin Ambuhl (mambuhl AT earthlink DOT net)
Note: mambuhl AT tiac DOT net will soon be inactive

- Raw text -


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