void main()
{
fflush(stdout);
int n ;
cout <<"enter the number of values u want";
cin>>n;
int* list = newint[n];
cout<<endl<<"enter the list"<<endl;
for ( int counter = 0; counter <n;counter ++)
{
cin>>list[counter];
}
for ( int counter = 0; counter <n;counter ++)
{
cout<<list[counter]<<" , ";
}
_getch();
}
Hello,
I just wrote the following program and tried to input "3r" when i know i should only type int when the program asks for a int.I am getting a weird output and can someone explain me what is happening inside the compiler that is making this happen ?.I am automatically getting 3 numbers . Thanks!
OUTPUT:
enter the number of values you want 3R
enter the list-
-842150251,-842150251,-842150251
"r" is not a number, so it cannot be stored in an object of type int. The input attempt at line 12 fails (btw, you should check if the input succeeded), and nothing is ever written to your array.
The output you're seeing is Microsoft's debug mode value "uninitialized heap memory"