Segmentation fault (core dumped)

can sameone help to know why when I insert the first and last and phone number my code dumped
//////////////////////////////
myRolodex Command: I
Enter card: name phone
slex john 415 555 4444

Segmentation fault (core dumped)
//////////////////////////////////

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
  P#include<stdio.h>
#include<string.h>

struct Card
{
  char last[10];
  char first[10];
  char  phone_number[12];
};
typedef struct Card card;
#define array_size 100

void read_command(char* c);
void evaluate_command(char* c,card * newCard);
void insertCard(card * newCard);
void printCard(card *newCard);


int main ()
{

 char* c ;
 char command ;
 card newCard[array_size];
 read_command(c);
 evaluate_command( c, newCard);



return 0;
}
//===========================================================
void read_command(char* c)
{

   printf("myRolodex Command: ");
   scanf("%c" ,c);


}
//===========================================================
void evaluate_command(char* c,card *newCard)
{
  // card newCard[array_size];

  switch(*c)
  {
   case 'I' :
              insertCard(newCard);

   case 'P' :

               printCard(newCard);

   default :
             printf("Invalid command \n");

  }
//===============================================
   void insertCard(card *newCard)
{
    
  printf("Enter card: name phone \n ");
  scanf("%s ",&newCard->last[i]);
  scanf("%s ",&newCard->first[i]);
  scanf("%s", &newCard->phone_number[i]);
  
}

//==========================================================
void printCard(card *newCard)
{
    int i ;
    for(i = 0 ; i < array_size ;i++)
    {
    //   printf("Enter card: name phone \n ");
        printf("%s " , newCard->last[i]);
        printf("%s ", newCard->first[i]);
        printf("%s", newCard->phone_number[i]);
    }
}


closed account (SECMoG1T)
Hi the problem could be here
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

 void insertCard(card *newCard) 
  { 
     printf("Enter card: name phone \n ");
     scanf("%s ",&newCard->last[i]);/// are you reading to the address of a pointer? 
     scanf("%s ",&newCard->first[i]);
     scanf("%s", &newCard->phone_number[i]); 
  } 

 void insertCard(card *newCard) 
  {
      printf("Enter card: name phone \n "); ///why not just use this
      scanf("%s ",newCard->last[i]); 
      scanf("%s ",newCard->first[i]); 
      scanf("%s", newCard->phone_number[i]);
   } 

Good luck
Topic archived. No new replies allowed.