I have a C consloe application in windows using Visual Studio Pro 6.0 that gives a runtime error: Debug Error! During the scanf line.
If I put a printf loop in after the scanf loop to print the values to the screen it runs and it is clear everything is reading ok. I remove the printf and it won't run at all. I pared down the program until I got to the bare minimum code I could while keeping the error. Any insight as to what the cause is would be greatly appreciated.
rob
\/ 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\\pram ref%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