|
|
back to boardWhy the "for" stopped Posted by Lucas 5 Jan 2017 07:04 'n' is the number of test cases and 'res' it's a function that print the number of positions that can go. The problem is that it only reads one case, for example "a2", prints the result and ends the execution. Why that happen? void res(char p[2]); int main () { int i,n; char pos[2]; scanf("%d", &n); for(i=0; i<n; i++) { scanf("%s", &pos); res(pos); } Edited by author 05.01.2017 08:22 Re: Why the "for" stopped You need at least 3 chars for pos - for ending zero char. Probably it ruined n during first "scanf("%s", &pos);" |
|
|