Thanx - about using a structure
Thanx all especially garfield this helps alot. C_coder. I thought about using a structure but wasn't sure how to read it in. Would I just read the whole line in as a string.
ie:
fscanf(Filein, "%s", strucGrade);
When I Read get alot of junk
I get alot of junk along with the data I am not getting this please help.
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
char line[200];
char studnum[5];
char studnam[25];
char curr[3];
char grades[2][8];
int test[4];
char final[3];
FILE *fp;
fp = fopen("StuGrade.txt", "r"); /* for "filename", insert a file or var */
if (fp == NULL) /* Invalid file */
printf("Invalid file\n");
fgets(line, sizeof(line), fp);
sscanf(line, "%s%*,%[abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ]%*,"
"%s,%s,%s,%s,%s,%s,%s,%s,%s,%d,%d,%d,%d,%c,%c,%c," ,
studnam, studnum, curr, grades[0],
grades[1], grades[2], grades[3], grades[4],
grades[5], grades[6], grades[7], &test[0],
&test[1], &test[2], &test[3], final);
printf ("%s%s%s%s%s%s%s%s%s%s%s%d%d%d%d%c%c%c",
studnam, studnum, curr, grades[0],
grades[1], grades[2], grades[3], grades[4],
grades[5], grades[6], grades[7], &test[0],
&test[1], &test[2], &test[3], &final[0], &final[1], &final[2]);
cin.get();
return 0;
}