is it right ?

Write a code segment to read a list of 100 names and store it in memory. Assume each name does not contain more than 20 characters.


solution :
char N[100][20];
for(int I=0; I<=99; I++)
cin>>N[I];


is it rightt ???
or i have to right
cin >> N[i][j] ; instead of cin>>N[I];
I prefer using this,,,, works with spaces too

cin.getline(N[I],21);
Last edited on
cin >> N[i][j]; reads in a single character, while
cin>>N[I]; reads in an array of characters. In the last case take care of the number of characters being read!
Topic archived. No new replies allowed.