title: How to properly scan in input into a struct in C and display it back out?
body: <p>So i have a struct named person with all their information and i want the user to be able to input them and then display it all back to the user. Here is what I have:  </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  struct person{
      char name[30];
      char address[30];
      int phoneNumber[30];
      char creditRating[30];
  };
  
  int main(){
      struct person p;
      printf("What is the person's name?\n");
      scanf(" %s", p.name);
      printf("What is the person's address?\n");
      scanf(" %s", p.address);
      printf("What is the person's phone number?\n");
      scanf("%d", &amp;p.phoneNumber);
      printf("What is the person's credit rating?\n");
      scanf(" %s", p.creditRating);
  
      printf("The person's name is %s\n", p.name);
      printf("The person's address is %s\n", p.address);
      printf("The person's phone number is %d\n", p.phoneNumber);
      printf("The person's credit rating is %s\n", p.creditRating);
      return 0;
  }
  </code></pre>
  
  <p>My issue is that it won't properly take in an address that has spaces and numbers. Also, when i input a phone number, it doesn't properly display. All the numbers are random. How do I fix this?</p>