當我嘗試運行一段代碼時,我一直在收到這個錯誤,說這個變量正在被使用,雖然我聲明瞭它沒有被初始化。變量不初始化
{
FILE *fptr;
int length;
int number_search;
struct student
{
char surname[15];
char initials[6];
char title[4];
int student_number;
char module_name[25];
char module_code[7];
int assesment_mark;
int exam_mark;
int tuition_fee;
};
struct student record_student;
struct student *student_ptr;
student_ptr=&record_student;
length=sizeof(struct student);
printf("2 has been called\n");
printf("Enter module code: \n");
scanf("%s", module_code);
clear_buffer(module_code);
printf("%s\n",module_code); /*Test the string entered is 6 charaters, AB1234 format*/
if (! modcheck(module_code)) /*Change this fucntion to a differnt one to check correct format*/
{
printf("Invalid input\n");
}
else
{
printf("input ok\n");
printf("Enter Student Number: \n");
scanf("%d",number_search);
}
它說,int number_search
isn't being initialized
,儘管它的代碼是以上。