I am writing a program controlled file for pelles c and when I run it I get this error message ***processed returned 255***. I am running windows 7 as my os.
Sorry we miss the crystal ball here... ;D
Post the code.
Merry Xmas
Sorry bout that,
Here is the code:
#Include <stdio.h>
#define KMS_PER_MILE 1.609
int
main (void)
{
double miles,kms;
FILE *inp,*outp;
inp = fopen ("c: distance.txt", "r");
outp = fopen ("c: distout.txt", "w");
fscanf (inp, "%lf", &miles);
fprintf(outp, "The distance in miles is %.2f.\n", miles);
kms = KMS_PER-MILE * miles;
fprintf (outp, "That equals %.2f kilometers.\n", kms);
fclose(inp);
fclose (outp);
return (0);
}
The code when ran crashes and outputs error message ***process returns 255***.
Thanks for any help you can give in advance.
Just for Xmas the solution for an assignement ;D
#include <stdio.h>
#define KMS_PER_MILE 1.609
int main (void)
{
double miles,kms;
FILE *inp,*outp;
inp = fopen ("distance.txt", "r");
if (!inp) //Chek if opening was ok!!!!
{
printf("Can't open input file!\nProgram will terminate\n");
return -1;
}
outp = fopen ("distout.txt", "w");
if (!outp) //Chek if opening was ok!!!!
{
printf("Can't open output file!\nProgram will terminate\n");
return -1;
}
fscanf (inp, "%lf", &miles);
fprintf(outp, "The distance in miles is %.2f.\n", miles);
kms = KMS_PER_MILE * miles;
fprintf (outp, "That equals %.2f kilometers.\n", kms);
fclose(inp);
fclose (outp);
return (0);
}
If you really wanto open files on C: root don't leave spaces!
inp = fopen ("c:distance.txt", "r");
Not
inp = fopen ("c: distance.txt", "r");
Quote from: frankie on December 30, 2014, 11:24:46 PM
Just for Xmas the solution for an assignement ;D
#include <stdio.h>
#define KMS_PER_MILE 1.609
int main (void)
{
double miles,kms;
FILE *inp,*outp;
inp = fopen ("distance.txt", "r");
if (!inp) //Chek if opening was ok!!!!
{
printf("Can't open input file!\nProgram will terminate\n");
return -1;
}
outp = fopen ("distout.txt", "w");
if (!outp) //Chek if opening was ok!!!!
{
printf("Can't open output file!\nProgram will terminate\n");
return -1;
}
fscanf (inp, "%lf", &miles);
fprintf(outp, "The distance in miles is %.2f.\n", miles);
kms = KMS_PER_MILE * miles;
fprintf (outp, "That equals %.2f kilometers.\n", kms);
fclose(inp);
fclose (outp);
return (0);
}
If you really wanto open files on C: root don't leave spaces!
inp = fopen ("c:distance.txt", "r");
Not
inp = fopen ("c: distance.txt", "r");
Close but no cigar!
This will (try to) open the file in the current folder on the C: drive, most likely that of the C compiler installation.
To access a file in the root of the C: drive you have to properly use a "\" after the drive designation "C:", so the right instruction would be
inp = fopen ("c:\distance.txt", "r");
Ralf ;)
I tried all of them and the out put reads as follows: Can't open input file and program will terminate.
Quote from: Bitbeisser on December 31, 2014, 02:17:39 AMTo access a file in the root of the C: drive you have to properly use a "\" after the drive designation "C:", so the right instruction would beinp = fopen ("c:\distance.txt", "r");
Are you sure you get
c:\distance.txt with a single backslash?
Previous topic was already here (http://forum.pellesc.de/index.php?topic=6521.msg24300#msg24300) and a stupid question:
Have you that 'distance.txt' anywhere ?
If it is in C: root then this may work too:
inp = fopen ("c:/distance.txt", "r");
He forgot to create the input file ;)
Quote from: jj2007 on December 31, 2014, 03:44:50 AM
Quote from: Bitbeisser on December 31, 2014, 02:17:39 AMTo access a file in the root of the C: drive you have to properly use a "\" after the drive designation "C:", so the right instruction would beinp = fopen ("c:\distance.txt", "r");
Are you sure you get c:\distance.txt with a single backslash?
Oops :-[, of course not. Just had been working all day in Pascal, so I missed that. It needs to be of course
inp = fopen ("c:\\distance.txt", "r");
Ralf
I found and fixed the problem! All the help I got here was tremendous! The problems was with my computer. My hard drive was corrupted. That's why I was getting the *** processed returned 255***.
Once again thanks everyone for there help! Got a an 85% on my assignment!