I'm required to implement the get_string
method in order to ask user for input but I'm having trouble running the program though I think I have followed the steps correctly.
Here's my code:
#include <stdio.h>
#include <cs50.h>
int main(void)
{ string name = get_string("What is your name?\n");
// string name= get_string("What is your name, huh? \n");
printf("hello, %s\n", name);
}
Now to run the program, I type in ./hi
( hi is the folder name) to compile and the ls.. when I type clang hello.c
( hello.c is the name of the file I'm writing in) I get error.. I do not understand the difference between clang hello.c
and ./hi
..
Instead of running clang, try running $ make hello.c
This should make a file named hello. The terminal will also show you all the compiler arguments CS50 has added to clang. You should then be able to run using $ ./hello
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.