Hi,
I am trying to write a simple program that stores a user input in a c-string,and will then print out each character (I)diaganolly across screen and (II) each character on a new line.
The problem im having with this,and with c strings entirely,is that it keeps printing out random characters that are stored in the array,after it has printed out the ones that have been input into it.
For example:
main()
{
char user_input[10];
int setnum ; // set precision number
cin >> user_input;
for(int i=0; i < 10 ; i++)
{
cout << user_input[i] ;
cout << endl;
}
is supposed to display each char on a new line,which it does,but then displays random characters until the end of array.
Is there anyway to stop this?