Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

debug error using struct

Status
Not open for further replies.

DevelopmentTools

Programmer
Mar 8, 2006
1
0
0
DE
#include "def_struct.c"
int main()
{
float Max_Eval;
int level =0;
result=PSO(level, Max_Eval);
}
where pso is a structure
struct position PSO(int level, float Max_Eval)
{
int add_option=1;
int already;
.........
}

and struct position is defined in def_struct.c
struct position {struct vector p;struct f f;};
struct position PSO(int level, float Max_Eval);

When I debug the code,the program throws an exception while trying to call pso.Can anyone help me in this regard.
 
1. Please use [code][/code] tags when posting code.

2. If you want people to find a crash, then you're going to have to post actual code which crashes.

Random snippets of information which neither compile, nor contain all the information just waste everyones time.

If the code is particularly long, then try removing code to something which shows the problem and is manageable enough to post (couple of hundred lines max).

> throws an exception while trying to call pso
Like which one?
Exact text please, not some fuzzy recollection of yesterdays attempt.

--
 
At a guess, it is because you're returning a structure on the stack. Either create the result as a static or create it on the heap. If you create it on the heap, remember to delete it. If you create it as a static remember that the values will change every time you call it.
 
Whydoesalmosteverynewprogrammernowdaysnotuseanywhitespaceatallintheircode?Itmakesmyeyeshurtjustlookingatit.There'sareasontheyputaspacebar,tabkeyandenterkeyonthekeyboard;they'renotjustfordecoration...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top