1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
// Proj 6.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
int _tmain(int argc, _TCHAR* argv[])
{
int id, number, balance;
char name[30];
FILE *textFile = fopen ("I:\\Documents\\p6.txt" , "r");
if(textFile== NULL)
perror ("Error opening file");
else{
printf ("\n\n-------------\nFile Opened\n------------\n\n");
printf ("%-10s%-10s%-10s%-10s", "ID", "NAME", "NUMBER", "BALANCE");
fscanf (textFile, "%d%s%d%d",&id, name, &number, &balance);
while (!feof){
printf ("%-10d%-10f%-10d%-10d\n", id, name, number, balance);
fscanf (textFile, "%d%s%d%d",&id, name, number, &balance);
}
fclose (textFile);
printf ("\n\n\n\n-------------\nFile Closed\n-------------\n");
}
return 0;
}
| |