paulina_lui
May 7th, 2003, 04:44 PM
Hi All,
I want to Read/Write a structure like this from/to a file
struct{
char[12] id;
int height;
int width;
}
Now some times the structure with same id will be written to the file more then once, so I wan't to write all the structures with same id together.
But the structures with same ids don't come together for example the program flow can be like this...
write strcut1 (id="hey")
write strcut2(id="hola")
write strcut3(id="aloha")
write strcut4 (id="hi")
write strcut5 (id="hey")
So I wan't to write all the structs with id hey together, as I have to read from this file later on to print a summary report of how many times one particular id came and corresponding struct values.
So if I write them one after the other as they come without any sorting, I will have to parse the whole file again and again for each id, but however if all of the same ids are written together, I can get the repetition count for the moment the id changes
if(struct id is not different)
count++;
I am not very good at c, but have been told that for file io its the fastest and is the way to go, because in my case the file can get big.
Have worked in C++/MFC, but never really with the file ios and stuff.
So any help is greatly appreciated and VERY MUCH NEEDED :-)
Pauli
I want to Read/Write a structure like this from/to a file
struct{
char[12] id;
int height;
int width;
}
Now some times the structure with same id will be written to the file more then once, so I wan't to write all the structures with same id together.
But the structures with same ids don't come together for example the program flow can be like this...
write strcut1 (id="hey")
write strcut2(id="hola")
write strcut3(id="aloha")
write strcut4 (id="hi")
write strcut5 (id="hey")
So I wan't to write all the structs with id hey together, as I have to read from this file later on to print a summary report of how many times one particular id came and corresponding struct values.
So if I write them one after the other as they come without any sorting, I will have to parse the whole file again and again for each id, but however if all of the same ids are written together, I can get the repetition count for the moment the id changes
if(struct id is not different)
count++;
I am not very good at c, but have been told that for file io its the fastest and is the way to go, because in my case the file can get big.
Have worked in C++/MFC, but never really with the file ios and stuff.
So any help is greatly appreciated and VERY MUCH NEEDED :-)
Pauli