Hi, I am trying to take information from one file and write parts of it to another. The file that I'm taking information from looks something like this:
230943455...etc (about 100 digits or more)
100101990610...etc
101101990711....etc
101101990610....etc
284923938....etc
The first line and the last line is some kind header and trailer information that I don't need and I would like to skip them. The lines in the middle contain information that I want to make readable. After the first 6 digits you can see a date..990610 (oct 6,1999)(there is more to get in the file but if I can get the date, I feel like I can get the rest) Then I'm trying to take that information and write it to another file. The code that I wrote creates the new file but there is nothing written to it. I hope someone can take a look and tell me how write this correctly. To you more advanced programmers, I must warn you...the code you are about to see may be disturbing and might keep you up at night!
I have not attempted to add code to skip the first and last lines because I have no idea how to begin. Hammer and jabrams have given me some pointers on this; however, I have been unsuccessful. Any help would be greatly appreciated! McornCode:/* #include<stdio.h> #include<stdlib.h> #include<conio.h> #include<string.h> #include<ctype.h> #include<mem.h> #define max 400 FILE *test; FILE *test1; void parse(char *){ } void main(void){ char word[max]; char *ptr; char date1[20],date2[20],date3[20]; char slash[20]={"/"}; int date; //the address is numbers...int, char....how do I declare? test1=fopen("c:\\mark.txt","w"); test=fopen("c:\\test.txt","r"); //pointer must go to a location? fgets(word,max,test); while(!feof(test)){ strcat(date2,slash); strcat(date2,date3); strcat(date2,slash); strcat(date2,date1); memset(word,'\0', sizeof(word)); parse(word); ptr=word; ptr=ptr+6; memcpy(&date,ptr,6); fclose(test); fclose(test1); } //system("pause"); } */