0

Watching the first week 1 lecture, they went over how you need "\n" to print a new line. However in the example: { printf("Your name please: "); string s = GetString(); printf("hello, %s\n", s); }

the second printf line prints on a new line without any need for \n. I thought we had to tell the computer to go to a new line. Is it built in to the GetString function?

1

When you run this program, you indicate to the computer that you are finished entering your name by doing something. That "something" is where the new line in question comes from.

| improve this answer | |
  • So, the user typing an answer indicates to the computer that it can go on to a new line? – lawcooper Nov 12 '15 at 18:18
  • 1
    Not quite. User has to hit the enter key to "finish" the entry. "enter" moves the cursor to the next line. – DinoCoderSaurus Nov 12 '15 at 20:54

You must log in to answer this question.

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