Function inside Struct Question

I have this code in a project that I'm working on:
1
2
3
4
5
6
7
8
9
10
11
12
struct TrackSegment
{
	const unsigned int NumSplines;
	unsigned int SplineIDX[];
	void AddSpline()
	{
		for (int i = 0; i < NumSplines - 1; i++)
		{
			SplineIDX[i] = i;
		}
	}
};


This is going to be a part of a file structure. If NumSplines = 5, how many instances of SplineIDX[] will be created? If too many are created, then the file will become corrupt. The compiler is not giving me any errors with this code, which I believe that means that all I have to do is put in the "main" function (which I haven't done yet) and it'll run just fine (though useless right now since I don't have a file handler), right? And will the function be run automatically when the structure is called?

PS: This bit of code only tells which splines (not included in code snippet) are used by the segment.
well if numsplines is 5 then splineidx[] will have 4 because you put a -1 after numsplines in your loop as to the other stuff I won't be of much use
Okay. I get it I think.

What about the initial declaration of SplineIDX[]? Will that not create an instance in addition to what the loop creates?
it souldnt, you could always do like cout << SplineIDX[i] and put that in the loop to see or even put it before the loop and see if the first one shows up with out the i ofcourse.
Okay, but I've already set the application that this code is going in as a windows application. I though that the "cout" command was only for console applications.
well depends on what IDE you are using some have an output menu on the bottom, you could also use the print function, puts function, or put the output into a text file, or just simply copy your function and put it into a console app before putting into your other app. you should be able to use cout << though and just look at the output on the bottom of ur ide where it shows the errors and stuff
Well, I think I figured out how to do this but it's going to take me to recoding everything and just map everything instead of just some things.
Wish me luck, thanks for all the help.
Topic archived. No new replies allowed.