471,075 Members | 988 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,075 software developers and data experts.

runtime error seems to be caused by scanf in VSP 6.0

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.


\/ 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[])

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);


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
1 1899
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.

Jul 4 '06 #2

Post your reply

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

Similar topics

7 posts views Thread by cppaddict | last post: by
6 posts views Thread by Peter Frost | last post: by
3 posts views Thread by Antti Keskinen | last post: by
2 posts views Thread by Massimo Soricetti | last post: by
4 posts views Thread by John Doe | last post: by
9 posts views Thread by Brian Dude | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.