Structure Within Structure
I am learning C from Deitel & Deitel''s How To Program book. I am trying to learn how to create a structure within a structure.
I want the user to key in the particulars like name and age, etc and use the pointers and arrow pointers to refer to the data input in the structure.
I have not finished coding yet and I faced this problem with my code.
Code:
#include<stdio.h>
struct student {
char Name[20];
char Surname[20];
int studentNumber;
struct {
char telNumber[10];
char Address[50];
} personal;
} studentRecord, *studentPtr;
int main(void)
{
studentPtr = &studentRecord;
printf("Enter student name: \n");
scanf("%c", &Name);
printf("Enter student surname: \n");
scanf("%c", &Surname);
return (0);
}
I haven't finished coding yet but when I compiled I received this message in my Mocrosoft Visual C++ compiler :
error C2065: 'Name' : undeclared identifier.
What is wrong with my "scanf("%c", &Name);" ?
Should I declare char Name [20] in main again after declaring it in the structure ?
I appreciate your help very much as I have no one to consult. I am learning C on my own.