delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/10/27/18:46:23

From: MCheu <mpcheu AT yahoo DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Compilation Error
Organization: Metronome
Message-ID: <mmtoru0p34clhpsq56oam0unu8qrur5nb7@4ax.com>
References: <S2Yu9.29661$Mb3 DOT 1242994 AT bgtnsc04-news DOT ops DOT worldnet DOT att DOT net>
X-Newsreader: Forte Agent 1.92/32.572
MIME-Version: 1.0
Lines: 50
Date: Sun, 27 Oct 2002 18:33:28 -0500
NNTP-Posting-Host: 209.188.71.240
X-Trace: localhost 1035761613 209.188.71.240 (Sun, 27 Oct 2002 16:33:33 MST)
NNTP-Posting-Date: Sun, 27 Oct 2002 16:33:33 MST
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Sun, 27 Oct 2002 20:31:46 GMT, "Peter" <peter_data2002 AT yahoo DOT com>
wrote:


>
>#include<iostream>
>
>int main()
>{
>    char *str1 =new char(100);
>    char *str2=str1;
>
>    cout <<int(str1) << "address of  str2 is "  <<int(str2)<<"\n";
>    *str2++ = 'T';
>    *str2++='E';
>    cout<<"value of str1 is "<<str1<<"\n";
>    return 1;
>}
>
>
>iostrem is located in "c:\djgpp\lang\cxx\3.2\"
>
>I would appreciate help on resolving the issue.
>
>Thanks
>


The error might be in your code.   You seem to be using the new style
headers but aren't using the namespace correctly.

You can either globally specify the namespace:

#include <iostream>
using namespace std;

or

prefix the cout lines with std::  to specify the namespace locally.

eg.     std::cout <<"value of str1 is " << str1 << endl;

This second style is preferred, as it's more flexible, but the first
style is sometimes more convenient.


-----------
Thanks

MCheu

- Raw text -


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