//this code Don't work
//Output Should Be "Hello World " But isn't (it's nonsense or null)
[cpp]
#include<strstrea.h>
#include<string.h>
char token1[100];
char token2[500];
char first[500];//Ambiguity line
void main()
{
istrstream ST(first);
strcpy(first,"Hello World");
ST>>token1;//Part That don't work Correctly
ST>>token2;//Part That don't work Correctly
cout<<token1;
cout<<token2;
}
[/cpp]
//Output has error
//but when I move this ambiguity line : char first[500];
into the main function it works correctly
[cpp]
#include<strstrea.h>
#include<string.h>
char token1[100];
char token2[500];
void main()
{
char first[500];//Ambiguity line
istrstream ST(first);
strcpy(first,"Hello World");
ST>>token1;//Part That don't work Correctly
ST>>token2;//Part That don't work Correctly
cout<<token1;
cout<<token2;
}
[/cpp]
Anybody could Explain Difference of First code and second where I move that line?
an Ambiguity in istrstream
Moderator: Board moderators
Compiler?
Hi,
Which compiler are you using? It seems to be a compiler problem, while handling global data.
- Suman
Which compiler are you using? It seems to be a compiler problem, while handling global data.
- Suman