Run-time check error..

Hello guys, Im a very inexperienced programmer..Ive only used this C+ once and Im not very good at it whatsoever..However, Im supposed to be taking data from a file named suture.dat which contains various numbers regarding batches of sutures, and printing the information onto the black screen in Microsoft visual 2008. Below is my code. When I try to debug the program, the following error message pops up "Run-time-check error, variable 'batch' being used without being initalized."

Can anybody help me with this problem?? See anything wrong with my program??


#include<stdio.h>

void main()
{

int batch;
int temp;
int pressure;
int dwell;
FILE * reader;

reader=fopen("suture.dat","r");

if(batch==0&&temp==0&&pressure==0&&dwe…
{
printf("End of program \n");

}

while(batch>0&&temp>0&&pressure>0&&dwe…
{

fscanf(reader,"%d %d %d %d",&batch,&temp,&pressure,&dwell);

}

printf("The values read from the files are %d %d %d %d \n",batch,temp,pressure,dwell);

}
Well, what does the error message say? Take a look at that message again, and tell me where you initialize batch or give it any value.
You created batch, but you didn't set it to anything.

So when you try to compare it in your if statement, you are comparing something that isn't initialized to 0.

Same with temp, pressure and dwell.

And your pointer isn't pointing at anything either.
Last edited on
Topic archived. No new replies allowed.