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:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
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", &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;
}
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?