file processing help! - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

file processing help!

luifranco09luifranco09 Posts: 2Member
Hi, okay I'm suppose to write a program that takes a text file(inputFile.txt) with a set format then the compiler will take the data and display it in a different format.

The original format is:
Name: John Milton
Major: EE
GPA: 3.98
Name: Karl Lewis
Major: CS
GPA: 3.6
Name: Homer Simpson
Major: CE
GPA: 4.0

and its suppose to look like this:
Name: Major: GPA:
John Milton EE 3.98
Karl Lewis CS 3.6
Homer Simpson CE 4.0


#include

void main()
{
FILE *fp;
int c;
fp = fopen( "C:\inputFile.txt", "r" );
if(c == EOF)
{
printf("file does not exist.");
}
while(c != EOF)
{
putchar(c);
c = getc(fp);
}
printf("
");
fclose( fp );
}
I got this so far but I dont know how to format into a different way. Any help on what to do next?
Sign In or Register to comment.