Char Pointer Array Compiler specific

This really simple program is giving weired results it compiles without any errors and runs properly if i don't declare c[10] (which is not used in program anywhere) on Code::Blocks 8.02 and Quincy 2005 (although it does not run properly on Dev C++ with or without declaration of char c[10];)

#include<iostream>
using namespace std;
int main()
{
char c[10]; //if this is kept as comment program will work fine.
char *t;
cin>>t;
cout<<t;
return 0;
}
Are you sure this is what you really want to do
1
2
char *t; //especially this line
cin >> t;
Last edited on
Well, you are right it is abusing pointers and the result is bound to be unpredictable,Thanx for help.
BTW this link (topic) on forum was really helpful for me http://www.cplusplus.com/forum/beginner/13343/
Last edited on
Topic archived. No new replies allowed.