+ 1

Hi guys does anybody can help to fix this code please

#include <stdio.h> #include <string.h> int maxstring(char s[][100], int n) { int max_i; char maxstr[100]; strcpy(maxstr, s[0]);max_i = 0; for(int i = 1; i < n; i ++) { if(strcmp(maxstr,s[i])<0) //line 10 { strcpy(maxstr, s[i]); max_i = i; } } return max_i; } int main() { char s[5][100]; int i; for(i = 0; i < 5; i++) scanf("%s",s[i]); int max_i = maxstring(s+2,3); //line 25 printf("%s\n", s[max_i]); return 0; }

23rd Dec 2018, 6:06 AM
SarvarCoder
1 ответ
0
Could you tell me the error ?
23rd Dec 2018, 9:14 PM
Vanessa Nilsson