save variables

Hi everybody,

how can I save a struct data in a file in a specific directory.

I defined a struct like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
  typedef struct
{
	unsigned short
		Label; // label indicatore del marker ?? MAGARI NON SERVE
	unsigned long
		ulFlags,
		ulFrameNumber;
	Position3d
		translation;
	int 
		OOV;

}TipoStrayMarker;

and i created an array of struct:
1
2
TipoStrayMarker
		StrayMarker[50];

During the execution of my program i would like to save the values of StrayMarker in a file.
My final purpose is:
- load these values (generated by my C++ program) in Matlab.


Thank you very much for your attention!
It sounds like you want to write the information to a file before closing your program. There are probably many ways to do this, but if I were doing it, I would use a simple ofstream and write the information out to a binary file.

The file would be set up with the first value being an integer that represents the number of structs behind it. If the code reading this file doesn't know about your structs, just put the information into the file lined up neatly.

You could write the information out to a textfile as well, but binary would make more sense since you are dealing with numbers.
Topic archived. No new replies allowed.