title: Cannot take string input properly in gcc ubuntu linux
body: <p>What is wrong in this program?? I am trying to figure out since 2 days but no help at all!!
  String output is only after string input and after selecting choice, default string input is new line character by default i guess. 
  Besides if i type string while inputting choice, it shows me the name output by default. Here is my code:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;string.h&gt;
  #include&lt;stdlib.h&gt;
  
  struct marks {
      char subject[15];
      int mark;
  };
  struct student {
      char name[10];
      int roll;
      struct marks m[3];
  };
  void displayData(struct student);
  int displayChoice();
  struct student getNewRecord();
  int main() {
      struct student s[5];
      int count = 0;
      int choice;
      do{
          choice = displayChoice();
          if(choice == 1){
              s[count] = getNewRecord();
              count ++;
          }
          else if(choice == 4)
              break;
          else
              printf("Invalid choice");
      }while(1);
  }
  struct student getNewRecord() {
      struct student temp;
      printf("Enter your Name : ");
      fgets(temp.name, 10,stdin   );
      printf("Your name is : %s",temp.name);
      return temp;
  
  }
  int displayChoice() {
      int choice;
      printf("\n\nPlease select your choice :\n");
      printf("1. Add new Record\n");
      printf("2. Display All data \n");
      printf("3. Remove last Record\n");
      printf("4. Exit the program\n");
      printf("What is your choice : \n");
      scanf("%d", &amp;choice);
      return choice;
  }
  void displayData(struct student s){
      printf("Your name : %s", s.name);
  }
  </code></pre>
  
  <p>And here are some screen shots:
  <img src="https://i.stack.imgur.com/ZnMcX.png" alt="enter image description here"></p>
  
  <p>I don't know and doesn't have any idea about what is going wrong. Please Help me..
  Thanks in advance..</p>