int main() { char str[10000]; gets_s(str); int num = 0, i=0; while (str[i] != '\0') { while (str[i] != ' '&&str[i] != '\0') i++; num++; while (str[i] == ' '&&str[i] != '\0') i++; } printf("%d", num); } /* Main.c: In function 'main': Main.c:4:2: warning: implicit declaration of function 'gets_s' [-Wimplicit-function-declaration] gets_s(str); ^~~~~~ Main.c:14:2: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration] printf("%d", num); ^~~~~~ Main.c:14:2: warning: incompatible implicit declaration of built-in function 'printf' Main.c:14:2: note: include '<stdio.h>' or provide a declaration of 'printf' Main.c:1:1: +#include <stdio.h> int main() Main.c:14:2: printf("%d", num); ^~~~~~ /usr/bin/ld: /tmp/ccsa1LRy.o: in function `main': Main.c:(.text.startup+0x11): undefined reference to `gets_s' collect2: error: ld returned 1 exit status */ |
Double click to view unformatted code.