Can anyone please tell me why my program will not compile
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.
What I'm trying to do is create an email address something like [email protected]rch
This is what I have got so far I think the problem lies with the function decleration but not sure, can anyone please help.
#include <stdio.h>
#include <string.h>
char *make(char *s);
int main()
{ char buffer[101], s[101] , *name[20] ;
char *mark, *test;
int i;
FILE *ifp, *ofp;
if ((ifp=fopen("scmemail.txt", "r")) == NULL)
printf("could't open scmemail.txt");
if ((ofp=fopen("email.txt", "w")) == NULL)
printf("couldn't open email.txt");
while(fgets(buffer,101,ifp) !=NULL)
{
strcpy(s,buffer);
switch(buffer[0])
{
case'#':break;
case'&'rintf("here now");
test = make(s);
break;
}
char *make(char *s)
{
i==0;
mark=strtok(s," &");
while(*mark != '-')
{
name[i++]=mark;
mark=strtok(NULL, " ");
printf("got this far");
}
return s;
}
fputs(mark,stdout);
/* fputs(mark,stdout);*/
/* fputs(buffer,stdout);/*
/* fputs(buffer,ofp); */
}
fclose(ifp);
fclose(ofp);
Thank you for any advise, I am new to C If anyone knows what I need to do would you explain to me, I want to be able to learn rather than just copy.