[Dev-C++] getting unexpected results
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: dawood <da...@ku...> - 2003-07-30 04:06:53
|
Can anybody let me know, why the below code is not working correctly.
#include <iostream.h>
#include <stdlib.h>
int main()
{
struct str_misc {
char* cstr;
};
str_misc str_ex[12];
char* buf;
cin>>buf;
str_ex[0].cstr= buf;
cout<<str_ex[0].cstr<<"index=0"<<'\n';
cin>>buf;
str_ex[1].cstr= buf;
cout<<str_ex[1].cstr<<"index=1"<<'\n';
cout<<str_ex[0].cstr<<" repeat index=0"<<'\n';
cout<<str_ex[1].cstr<<" repeat index=1"<<'\n';
system("PAUSE");
return 0;
}
|