removing/ignoring carrage returns from a file
Hi all,
I'm trying to pull data from a .dat file which is arranged like this:
F 26 5
F 64 4
F 29 2
M 12 3
M 40 1
Now I've got it pretty much working so far but the only issue I have is that there is a carrage return at the end of each line so when I output to the screen I get:
F 26 5
26 5
F 64 4
64 4
F 29 2
29 2
M 12 3
12 3
M 40 1
What I need to do is get the carrage return either not read or stripped from the output. so far my code looks like this:
Code:
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
//void bar(int number); // Layout
//void space(int number); // Layout
void main()
{
FILE *rawdat;
char sex;
int age;
int range;
rawdat = fopen("H:\\sp3work\\SP3Project\\custsurvey.dat","r");
if (rawdat == NULL)
{
printf("Cannot locate file");
}
else
{
while (fscanf(rawdat, "%c %d %d", &sex, &age, &range) != EOF)
printf("%c %d %d\n", sex, age, range);
}
if (fclose(rawdat) == EOF)
puts("Cannot close this file");
printf("\n\n\nPress any key to continue");
getch();
}
Any help would be greatly appreciated