Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How do I read a whole line in C?

  1. May 14, 2012 #1
    Code (Text):
    #include <stdio.h>

    int main()
        char name[256];
        printf("What's your name?\n");
        printf("Hello, %s%s",name,"!");
    This only reads the first word of the name inputted. Is there any way to get a whole line?
  2. jcsd
  3. May 14, 2012 #2


    Staff: Mentor

    gets will read a whole line of text.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook