dimanche 17 décembre 2017

The code is to input strings at run time but the code is accepting string one less than the mentioned sized n?Where is the error?

This is the code where it running for n-1 times why?

int main(){int n; cin>>n;char str[n][100];
for(int i=0;i<n;i++)
{char c; int j=0; 
 while((c=getchar())!='\n') 
 {  
 str[i][j++] = c; 
  }  
  str[i][j] ='\0'; 
  } 

Aucun commentaire:

Enregistrer un commentaire