#include"cs50.h" ヘッダーには、#include<cs50.h> のように入力する必要があります。また、やってみてください:
#include<cs50.h>
#include<stdio.h>
int main(void)
{
string name = get_string("Enter your name: ");
printf("%s\n", name);
}
これの代わりに:
#include "cs50.h"
#include <stdio.h>
int main(int argc, string argv[])
{
string name;
printf("Enter your name: ");
name = GetString();
printf("Hello, %s\n", name);
}
これにより、エラーメッセージが取り除かれます。
PS 2 週目に help50 について説明しますが、必要に応じて今すぐ使用できます。私自身、とても便利だと思いました。仕組みは次のとおりです: ターミナル ウィンドウ (./hello と clang を実行するウィンドウ) で、「help50 make hello」(引用符なし) と入力すると、次のように入力されます。 . 次に、エラー メッセージを解読し、より単純な言語で入力します。例えば:
#include <stdio.h>
#include <cs50.h>
int main(void)
{
string name = get_string("Enter your name: ");
printf("%s\n", name)
}
私は挨拶をします、そしてこれは現れます:
clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wshadow hello.c -lcrypt -lcs50 -lm -o hello
hello.c:13:21: error: expected ';' after expression
printf("%s\n", name)
^
;
1 error generated.
<builtin>: recipe for target 'hello' failed
make: *** [hello] Error 1
しかし、help50 make hello でそれを行うと、次のように表示されます。
clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wshadow hello.c -lcrypt -lcs50 -lm -o hello
hello.c:13:21: error: expected ';' after expression
printf("%s\n", name)
^
;
1 error generated.
<builtin>: recipe for target 'hello' failed
make: *** [hello] Error 1
Asking for help...
hello.c:13:21: error: expected ';' after expression
printf("%s\n", name)
^
;
Are you missing a semicolon at the end of line 13 of hello.c?
ご覧のとおり、私は自分の問題を認識し、修正することができます。Help50 は、エラー メッセージを理解できる言語に解読します。