By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,131 Members | 1,882 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,131 IT Pros & Developers. It's quick & easy.

runtime error seems to be caused by scanf in VSP 6.0

P: 4
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
Jul 3 '06 #1
Share this Question
Share on Google+
1 Reply


P: 4
Just for the record, it seems that this is a compiler bug. THis code runs fine in at least 3 other compilers across 2 different OSes with no problems.

rob
Jul 4 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.