My problems are these, what my program should do is read in from a file scmemail.txt, and write out to a file email.txt I've had this working but have lost it.

I also need to call a function make_name to tokenise lines in the file and then store the tokenised array of strings (last_name[i]) what i want to do is print out these strings in a loop but I can't get it to work, if I print out the strings and reference them last_name_[1],2 etc this works. but cannot get it to work in loop.

Can anybody help, I,ve include the file I'm working with any help would be greatly appreciated.

Thank you

#include <stdio.h>
#include <string.h>

FILE *ofp;
char *make_name(char *s);
char *a[20], *p, *name;
char *last_name[40];
int i;
int main()
{
char buffer [101], s[101];
char new_name[30]="";
FILE *ifp, *ofp;

if ((ifp=fopen("scmemail.txt", "r")) == NULL)
printf("The file scmemail.txt could't be opened or is corrupt'/n'");

if ((ofp=fopen("email.txt", "w")) == NULL)
printf("The file email.txt couldn't be opened for writting please check disk space'/n'");

while(fgets(buffer,101,ifp)!=NULL)
{
strcpy(s, buffer);
switch(buffer[0])
{
case'#':break;

case'&'rintf(" here now\n"); /*visual check*/
name=make_name(s);/*Call to function make_name*/
strcpy(new_name,name);
break;


}

}

fputs(name,ofp);
fclose(ifp);
fclose(ofp);

return 0;
}

char *make_name(char *s)
{
char *kurt;
// char *last_name[40];
int Count;

Count=0;
i=0;
kurt=strtok(s," &");

while(*kurt != '-')
{
last_name[i++]=kurt;

kurt=strtok(NULL," ");
}

for (Count=1;Count<i;Count++)
{
fputs(last_name[i],stdout);
}
printf(last_name[i]);


// fputs(last_name[0],stdout);
// fputs(last_name[1],stdout);
// fputs(last_name[2],stdout);

return s;
} /* end of make_name function */