Can anyone please help, I'm trying to read a file into my program and what I would like to do is ignore any line starting with a # and the subsequent lines that start with & tokenise.
for example an extract of the file I'm working with:
# SCM Students
&ABBOTT DARREN - 01 MSc COMP AIDED GRAPHICAL TECHNOLOGY APPLICATIONS
M00641X [email protected]rch
M00641X [email protected]-arkengarthdale
&ACHMET ALPER - 02 CERTIFICATE IN PROFESSIONAL DEVELOPMENT
L36092X [email protected]rch
L36092X [email protected]-arkengarthdale
What I want to be able to do is ignore the first line of the code then when we see & I would like to be able to tokenise ABBOTT and also DARREN.
I am new to C programming and to be honest I'm going round in circles any help would be very very welcome because I'm loosing the will to live.
At the moment all I've been able to do with any success is to get the file read in and to get the file printed out.
This is what I have so far, pretty lame I know.
#include<stdio.h>
#include<string.h>
int main()
{
char buffer [101];
FILE *ifp,*ofp;
ifp=fopen("scmemail.txt","r");
ofp=fopen("email.txt","w");
while (fgets(buffer,101,ifp) != NULL)
{fputs(buffer,stdout);
fputs(buffer,ofp);
}
fclose(ifp);
fclose(ofp);
return 0;
}
Thanks again for any help
I'm using a compilier called Pacific C with non ansci c features disabled