Code:
int i=0,j=0;
char hold[200], ch;
char *teamname, *lastname, *firstname, *email;
FILE *output = fopen("output", "w");
while( (ch = getchar())!=EOF)
{
do
{
hold[i++]=ch;
ch=getchar();
}while(ch != '\n'&& ch!=EOF);
hold[i]='\0';
i=0;
teamname=strtok(hold, ",");
lastname=strtok(NULL, ",");
firstname=strtok(NULL, ",");
email=strtok(NULL, "\0");
fprintf(output,"%s\n", teamname);
fprintf(output,"%s\n", lastname);
fprintf(output,"%s\n", firstname);
fprintf(output,"%s\n", email);
if(ch==EOF)
return;
yes, you are right about the last strtok...
the input is by < inputfile...
if i only print if its not null...
ie.
if(teamname) printf("%s",teamname)
its fine but mysteriously prints 3 newline...
but why would any of the string be NULL?
its also fine if i input via the keyboard...
thanks!