包含的代码完全不在书中,但它会返回错误.这本书有不正确的做法吗?我以前从未使用#include <string.h>过,#include <stdio.h>但我仍然不知道三个参数应该是什么.
#include <stdio.h>
#include <string.h>
int main(void)
{
char buffer[256];
printf("Enter your name and press <Enter>:\n");
fgets(buffer);
printf("\nYour name has %d characters and spaces!",
strlen(buffer));
return 0;
}
Run Code Online (Sandbox Code Playgroud)
编译说
Semantic issue with (fgets( buffer ); - Too few arguments to function call, expected 3, have 1
Format string issue (strlen(buffer)); - Format specifies type 'int' but the argument has type 'unsigned long'
Run Code Online (Sandbox Code Playgroud)