I have just do a program to cut a string to 2 string, space by tab, but when I run it was failed, could you fix help me?
the data.txt file have multilines, a line include a word, a tab and a word
Code:
void main()
{
clrscr();
FILE*f;
char*tr;
char chuoi[100];
char*dau;
char*cuoi;
int length;
f=fopen("E:/data.txt","r+");
while(!feof(f)-1)
{
fgets(tr,100,f);
strcpy(chuoi,tr);
dau=strtok(chuoi,"\t");
for(int i=0;i<(strlen(tr)-1);i++)
{
if(tr[i]=='\t')
{
strcat(cuoi,&tr[i+1]);
}
}
printf("%s",dau);
printf("-%s",cuoi);
strcpy(chuoi,"");
strcpy(dau,"");
strcpy(cuoi,"");
}
getch();
}