I am tryting to write a program in Visual Studio Pro 6.0, in C, and when I run it I get a urntime error: Debug Error!
when I originally had a loop after the scanf loop to print out the values that were read in, everything looked fine. I removed the printf and get the error, put the printf back in and the error goes away. Can anyone tell me what is wrong with this code and suggest how it might be fixed?
/ Multiequater2000.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
void CreateFCIPFiles();
int main(int argc, char* argv[])
{
CreateFCIPFiles();
return 0;
}
void CreateFCIPFiles()
{
struct itemInfo
{
int id, model, linking;
double a, b, c, thresh1, thresh2, thresh3, thresh4;
};
char line[80];
struct itemInfo items[78];
int conditionCounter, yearCounter, repCounter, itemCounter;
FILE *fpItemInfo;
conditionCounter = 0;
yearCounter = 1;
repCounter = 1;
sprintf(line, "equating_project\\condition%2.2i\\year%2.2i\\pramr ef%2.2i.txt", conditionCounter, yearCounter, repCounter);
if (( fpItemInfo = fopen( line, "r")) == NULL)
{
printf("Input specification file %s cannot be opened.\n\n", line);
exit (1);
}
for(itemCounter = 0; itemCounter<78; itemCounter++)
{
fscanf(fpItemInfo, "%i %i %i %lf %lf %lf %lf %lf %lf %lf", &items[itemCounter].id, &items[itemCounter].model, &items[itemCounter].linking, &items[itemCounter].a, &items[itemCounter].b, &items[itemCounter].c, &items[itemCounter].thresh1, &items[itemCounter].thresh2, &items[itemCounter].thresh3, &items[itemCounter].thresh4);
}
fclose(fpItemInfo);
}
this is a sample of the first line form the input file being read:
226316 1 0 1.02681 -0.93143 0.13604 0.00000 0.00000 0.00000 0.00000
when I originally had a loop after the scanf loop to print out the values that were read in, everything looked fine. I removed the printf and get the error, put the printf back in and the error goes away. Can anyone tell me what is wrong with this code and suggest how it might be fixed?
/ Multiequater2000.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
void CreateFCIPFiles();
int main(int argc, char* argv[])
{
CreateFCIPFiles();
return 0;
}
void CreateFCIPFiles()
{
struct itemInfo
{
int id, model, linking;
double a, b, c, thresh1, thresh2, thresh3, thresh4;
};
char line[80];
struct itemInfo items[78];
int conditionCounter, yearCounter, repCounter, itemCounter;
FILE *fpItemInfo;
conditionCounter = 0;
yearCounter = 1;
repCounter = 1;
sprintf(line, "equating_project\\condition%2.2i\\year%2.2i\\pramr ef%2.2i.txt", conditionCounter, yearCounter, repCounter);
if (( fpItemInfo = fopen( line, "r")) == NULL)
{
printf("Input specification file %s cannot be opened.\n\n", line);
exit (1);
}
for(itemCounter = 0; itemCounter<78; itemCounter++)
{
fscanf(fpItemInfo, "%i %i %i %lf %lf %lf %lf %lf %lf %lf", &items[itemCounter].id, &items[itemCounter].model, &items[itemCounter].linking, &items[itemCounter].a, &items[itemCounter].b, &items[itemCounter].c, &items[itemCounter].thresh1, &items[itemCounter].thresh2, &items[itemCounter].thresh3, &items[itemCounter].thresh4);
}
fclose(fpItemInfo);
}
this is a sample of the first line form the input file being read:
226316 1 0 1.02681 -0.93143 0.13604 0.00000 0.00000 0.00000 0.00000