#include <string.h> #include <stdio.h> void main(int argc, char *argv[]) { int len = 0; char chr[102]; char tmp[102] = "/""; char tmp2[102] = "/0"; FILE *fp,*fp2; //char *fname; if ((fp = fopen(argv[1],"r")) == NULL) { printf("open test.txt fail!/n"); } if ((fp2 = fopen("result.txt", "w")) == NULL) { printf("open result.txt fail!/n"); } while(!feof(fp)) { fgets(chr, 100, fp); if (strcmp(chr, "/n") == 0 || strcmp(chr,"") == 0) { continue; }else{ strtok(chr, "/n"); strcat(chr, "/","); strcat(tmp, chr); printf("%s/n",tmp); fputs(tmp, fp2); fputs("/n", fp2); //strcpy(chr, tmp2); strcpy(tmp, tmp2); strcpy(tmp, "/""); } } }