0

Ive been doing pset 1 Hello and at the last part about User Input, Im at a loss for what to do. On the instructions, there are some hints where it says two commands. When I put down the two commands I get an error saying unexpected token. So what it said was,

string name= get_string("What is your name?\n"); (When I put this in I get) bash: syntax error near unexpected token (' SECOND printf("hello %s\n", name); (When I put this in I get) bash: syntax error near unexpected token"hello,%s\n,'

And I also do not understand the general question. Do I just put in

string name= get_string("What is your name?\n); printf("hello, %s\n", name);

Any help is appreciated because the walkthroughs and tips have offered none. Thank you

PicturesMy code of hello.c

1
  • 1
    Ummm... exactly what are you doing? If you're getting a bash error, it sounds like you're trying to enter program code on a command line. OR, you've created the source code file and you're trying to execute that file instead of compiling and running the executable file that is created. You should be creating a file with all the source code inside it and then compiling it with the make command. This is a rare exception where a screen capture will best provide the answers. Please recreate the problem, take a screen capture, edit your question and insert the image.
    – Cliff B
    Jul 26, 2019 at 0:14

1 Answer 1

1

From your screenshot, you are typing the code into the terminal itself. That does not work.

You should be writing all of your code inside hello.c in the editor. Then, once you have done that, you run make hello to compile it, and then ./hello to run your code.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .