| delorie.com/archives/browse.cgi | search |
| X-Authentication-Warning: | delorie.com: mailnull set sender to djgpp-bounces using -f |
| From: | "J.W. Dare" <jwdare AT novia DOT net> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: strings |
| Date: | 14 Dec 2001 23:47:07 -0600 |
| Lines: | 39 |
| Message-ID: | <llol1u4nnfja3fr82oavkjfl6qi5na4scd@4ax.com> |
| References: | <LQyS7.2291$cd DOT 473157 AT news DOT uswest DOT net> |
| NNTP-Posting-Host: | 216.40.2.67 |
| X-Trace: | 1008395089 newscene.com 216.40.2.67 216.40.2.67 |
| Filter-NNTP-Posting-Host: | 216.40.2.67 |
| Filter-X-Trace: | 1008395089 newscene.com 95066 216.40.2.67 |
| X-Newsreader: | Forte Agent 1.8/32.548 |
| MIME-Version: | 1.0 |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
On Fri, 14 Dec 2001 20:46:51 -0600, "Derek" <djny AT flashmail DOT com>
wrote:
>I can't seem to get strings to work with DJGPP. I'm sure there's a simple
>solution. Could someone please point me in the right direction?
>
>Here's what I tried:
>
>#include <iostream>
>#include <string.h>
>
>int main()
>{
> string word = "test";
> cout << word << endl;
> return 0;
>}
>
>When I compile it, I get:
>
>Error: 'string' undeclared (first use this function)
>
>I tried many things and nothing worked. This is mind boggling. Would you
>mind pointing out what I'm doing wrong?
Change the
#include <string.h>
to
#include <string>
If you're using the latest DJGPP, based on gcc 3.02 then you'll also
need to either add the line
using namespace std;
or else reference the string type as std::string
--
J.W.Dare
jwdare AT novia DOT net
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |