0

This program when it receives the input 1, it receives info from the user and if the input 2 is given it shows what it has stored so far.

The issue is that when you select 2 after having inserted the required info, the name that was provided appears as NULL.

user17850871
  • 79
  • 1
  • 6
  • No `&`: `scanf("%[^\n]%*c", OE1);` -- `OE1` is an array; it gets automatically converted to a pointer (to its first element) when used as argument in `scanf()` function. – pmg Feb 25 '22 at 17:56

1 Answers1

1

Instead of

scanf("%[^\n]%*c", &OE1);
                  ^^^  

you need to write

scanf("%[^\n]%*c", OE1);

This statement

ptr -> OE[NAME_LEN]=OE1[NAME_LEN];

does not make a sense.

You need to write

#include <string.h>

//...

strcpy( ptr -> OE, OE1 );

This functionality of this if statement

   if(head==NULL)
     ptr->next=NULL;
   else
     ptr->next=head;

can be performed just by one statement

ptr->next = head;

And this statement

printf("%d     %s    %d\n",ptr->AM, ptr->OE[NAME_LEN], ptr->XS);

must be substituted for this one

printf("%d     %s    %d\n",ptr->AM, ptr->OE, ptr->XS);
Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335