Hello everyone!
I am struggling with executing my C program, so when I run my program the following error appears after this part of code
Code:
void getName(struct Name* name) {
char yesNo;
printf("Please enter the contact's first name: ");
scanf("%30[^\n]%*c", name->firstName);
printf("Do you want to enter a middle initial(s)? (y or n): ");
scanf("%s%*c", &yesNo);
if (yesNo == 'y' || yesNo == 'Y') {
printf("Please enter the contact's middle initial(s): ");
scanf("%6[^\n]%*c", name->middleInitial);
}
printf("Please enter the contact's last name: ");
scanf("%35[^\n]%*c", name->lastName);
}
And the error message is "Stack around the variable "yesNo"was corrupted". How can I fix that?