include <stdio.h> #include <string.h> int main() { int i=0,n=0; char a[100]; gets(a); for(i=0;i<strlen(a);++i) { if(a[i]!=' '&&(a[i+1]==" "||a[i+1]=='\0')) //注意右边条件 n++; } printf("%d",n); } /* Main.c:1:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token include <stdio.h> ^ In file included from Main.c:2:0: /usr/include/string.h:47:8: error: unknown type name 'size_t' size_t __n) __THROW __nonnull ((1, 2)); ^ /usr/include/string.h:50:56: error: unknown type name 'size_t' extern void *memmove (void *__dest, const void *__src, size_t __n) ^ /usr/include/string.h:66:42: error: unknown type name 'size_t' extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1)); ^ /usr/include/string.h:69:56: error: unknown type name 'size_t' extern int memcmp (const void *__s1, const void *__s2, size_t __n) ^ /usr/include/string.h:96:48: error: unknown type name 'size_t' extern void *memchr (const void *__s, int __c, size_t __n) ^ /usr/include/string.h:133:39: error: unknown type name 'size_t' const char *__restrict __src, size_t __n) ^ /usr/include/string.h:141:9: error: unknown type name 'size_t' size_t __n) __THROW __nonnull ((1, 2)); ^ /usr/include/string.h:147:57: error: unknown type name 'size_t' extern int strncmp (const char *__s1, const char *__s2, size_t __n) ^ /usr/include/string.h:154:8: error: unknown type name 'size_t' extern size_t strxfrm (char *__restrict __dest, ^ /usr/include/string.h:155:40: error: unknown type name 'size_t' const char *__restrict __src, size_t __n) ^ /usr/include/string.h:285:8: error: unknown type name 'size_t' extern size_t strcspn (const char *__s, const char *__reject) ^ /usr/include/string.h:289:8: error: unknown type name 'size_t' extern size_t strspn (const char *__s, const char *__accept) ^ /usr/include/string.h:399:8: error: unknown type name 'size_t' extern size_t strlen (const char *__s) ^ /usr/include/string.h:451:33: error: unknown type name 'size_t' extern void __bzero (void *__s, size_t __n) __THROW __nonnull ((1)); ^ Main.c: In function 'main': Main.c:7:6: warning: implicit declaration of function 'gets' [-Wimplicit-function-declaration] gets(a); ^ Main.c:10:27: warning: comparison between pointer and integer if(a[i]!=' '&&(a[i+1]==" "||a[i+1]=='\0')) ^ Main.c:10:27: warning: comparison with string literal results in unspecified behavior [-Waddress] Main.c:12:8: error: stray '\357' in program n++; ^ Main.c:12:8: error: stray '\274' in program Main.c:12:8: error: stray '\233' in program Main.c:14:6: error: expected ';' before '}' token } ^ Main.c:15:6: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration] printf("%d",n); ^ Main.c:15:6: warning: incompatible implicit declaration of built-in function 'printf' */ |
Double click to view unformatted code.