Why the following code throws an exception when moving to the second scanf_safter entering a number to place in the structure.
This in no way means implementing a complete linked list.
Not sure how to go to the next scanf_swhen entering a value? Any ideas?
EDIT: Updated code with the proposed solution, but still get it AccessViolationExceptionafter the firstscanf_s
the code:
struct node
{
char name[20];
int age;
float height;
node *nxt;
};
int FillInLinkedList(node* temp)
{
int result;
temp = new node;
printf("Please enter name of the person");
result = scanf_s("%s", temp->name);
printf("Please enter persons age");
result = scanf_s("%d", &temp->age);
printf("Please enter persons height");
result = scanf_s("%f", &temp->height);
temp->nxt = NULL;
if (result >0)
return 1;
else return 0;
}
int main(array<System::String ^> ^args)
{
node temp;
FillInLinkedList(&temp);
...
source
share