M
Madhur
Hello,
Suppose I have a structure like this:
struct LOGFILE
{
char timeStamp[100];
char Message1[100];
char Message2[100];
char Message3[100];
char Message4[100];
char Message5[100];
};
I have a memory mapped file (baiscally) and I want to read the file and
assign the values to this structure. Since the file is unstructured in
memory , I will parse and look for tab breaks and assign values accordingly.
Now, I want to do this in a loop. For ex:
LOGFILE *logFile; //Assume points to valid structure
void *fileData; //Pointer to file in memory (beginning)
for (int i=0;i<fileSizeByte;i++)
{
if(data=='\t')
{
memcpy(spLog->timeStamp,fileData,i);
}
}
Now , as the next text is found after tab, I want to copy it in message1,
then message 2 and so on. And then repeat copying to the new structure
pointer. Is it possible to do it transparently, without explicitly
duplicating the code for each structure member ?
Thanks,
Madhur
Suppose I have a structure like this:
struct LOGFILE
{
char timeStamp[100];
char Message1[100];
char Message2[100];
char Message3[100];
char Message4[100];
char Message5[100];
};
I have a memory mapped file (baiscally) and I want to read the file and
assign the values to this structure. Since the file is unstructured in
memory , I will parse and look for tab breaks and assign values accordingly.
Now, I want to do this in a loop. For ex:
LOGFILE *logFile; //Assume points to valid structure
void *fileData; //Pointer to file in memory (beginning)
for (int i=0;i<fileSizeByte;i++)
{
if(data=='\t')
{
memcpy(spLog->timeStamp,fileData,i);
}
}
Now , as the next text is found after tab, I want to copy it in message1,
then message 2 and so on. And then repeat copying to the new structure
pointer. Is it possible to do it transparently, without explicitly
duplicating the code for each structure member ?
Thanks,
Madhur