C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28629
Number of posts: 94611

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
file processing help! Posted by luifranco09 on 1 Dec 2012 at 1:39 PM
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 <stdio.h>

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("\n");
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?
Thread Tree
luifranco09 file processing help! on 1 Dec 2012 at 1:39 PM



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.