Hello,
I'm a learner. Compiler: MinGW Developer Studio, O/S:Win'98SE.
The program is a mail manager, taken from my "C"
book:"C by Example". On compilation, I'm getting the
warning:"Unused variable'list'"; on the line:"struct
mail_struct list[MAX];", just after,int main(){.
This variable is not used anywhere else in the book;
in my program, so I'm stumped. If I remove it, I get
the error:"syntax error before token."
It seems as though, it's a use,or remove issue.
How do I safely remove this variable; or where in my
program do I use it?
I'll only post the offending part of the program.
Thank you.
I'm a learner. Compiler: MinGW Developer Studio, O/S:Win'98SE.
The program is a mail manager, taken from my "C"
book:"C by Example". On compilation, I'm getting the
warning:"Unused variable'list'"; on the line:"struct
mail_struct list[MAX];", just after,int main(){.
This variable is not used anywhere else in the book;
in my program, so I'm stumped. If I remove it, I get
the error:"syntax error before token."
It seems as though, it's a use,or remove issue.
How do I safely remove this variable; or where in my
program do I use it?
I'll only post the offending part of the program.
Thank you.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
/*Global structure of name and address.*/
struct mail_struct
{
char name[25];
char address[25];
char city[20];
char province[20];
char zipcode[7]; /* Extra NULL character.*/
char code [10]; /*For additional expansion.*/
};
/*Global file pointer.*/
FILE *fp;
/*Defined constants.*/
/*MAX is the total number of names allowed in memory for reading
mailing lists.*/
#define MAX 250
#define FILENAME "ADDRESS.DAT"
/*Prototype all of the program's functions.*/
int main(void);
void disp_menu(void);
void enter_name(void);
int change_name(void);
void print_name(void);
void flush_newline(char *line);
void add_to_file(struct mail_struct item);
char pr_data(struct mail_struct item);
void get_new_item(struct mail_struct *item);
void pause_sc(void);
int getzip(char zipcode[]);
/**********************************************************/
int main()
{
struct mail_struct list [MAX]; /*Warning is here.*/
int ch;
do
{
disp_menu();
scanf(" %d", &ch);
while(getchar()!='\n');
switch(ch)
{
case(1) : {enter_name();
break;}
case(2) : {change_name();
break;}
case(3) : {print_name();
break;}
case(4) : {break;}
default : {printf("You need to enter");
printf(" 1 through 4");
break;}
}
}
while(ch != 4);
getchar();
return 0;
}