I am trying to write a code where it reads a file, save its content in array of structures and then try to give these variables to another application over an interval of some milliseconds. I can read the data from a file and store its values in "Filedata" structure. Now I am trying to copy the content of this structure into another. I thought two strategies for this. 1. Declare another variable in same structure and then copy the one structure into another.
struct Filedata { char *time; int t_diff; int SN; }; struct Filedata Data1[100]; struct Filedata Data2[100]; /* After reading and storing the content of file in Data1 Variable in main function and continuing in main*/ for (k=0; k<100;k++) { Data2 = Data1; printf("\t%d\n", Data2[k].SN); Sleep(Data2[k+1].t_diff); } 2. Or make another structure and then copy the content on first into second.
struct Target { char *time; int SN; int t_diff; }; struct Target Data3[100]; for (k=0; k<100;k++) { Data3[k].SN = Data1[i].SN; Data3[k+1].t_diff = Data1 [i+1].t_diff; printf("\t%d\n", Data3[k].SN); Sleep(Data3[k+1].t_diff); } I checked the code with debugger but it is not copying the content of first into another and just printing 0 for all values.
I read some post here about copying and used the assignment for copying, But somehow it is not working
Thanks much for your help.