using function inside switch statment in c

hey. i don't know why that when i call my function inside the switch statement nothing happened , I don't know where exactly the error, im talking about the function "insertCard " , because when I prompt the command "I" i get "invalid command" instead of calling the "insertCard" function , can someone help me plz
thank you

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
 #include<stdio.h>
#include<string.h>

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

void read_command(char c);
void insertCard(card * newCard);

int main ()

{
 char c;
 card newCard[array_size];
 read_command(c);

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


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

return 0;
}
//===========================================================
void read_command(char c)
{
 printf("myRolodex Command: ");
 scanf("%c" , &c);
}
//=============================================================
void insertCard(card *newCard)
{
  printf("Enter card: name phone \n ");
  scanf("%s " , newCard->last);
  scanf("%s ", newCard->first);
  scanf("%d", &newCard->phone_number);

}
//===================================================== 
You need to pass c into read_command as a pointer if you want to use it in your main.
at the moment it's making a copy.
here is my compiler's massive hint to me when I build:

1
2
(22): error C4700: uninitialized local variable 'c' used
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Last edited on
i did but still not working
Last edited on
any Ideas?
Topic archived. No new replies allowed.