CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2006
    Posts
    6

    debug error using struct

    I tried to execute the following code...

    #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.

  2. #2
    Join Date
    Feb 2002
    Posts
    4,640

    Re: debug error using struct

    What does your call stack look like? What line in "PSO" is throwing the exception?

    Viggy

  3. #3
    Join Date
    Mar 2006
    Posts
    6

    Re: debug error using struct

    The call stack looks like

    Tribes1.exe!PSO(int level=0, float Max_Eval=40000.000) Line 490 C

    The exception is thrown at the very first line in struct position PSO .

  4. #4
    Join Date
    Oct 2005
    Location
    Just moved to New Mexico
    Posts
    53

    Re: debug error using struct

    Could you post your whole struct ? yours doesn't look correctly-defined and that counts.
    MY tv is not bilingual, has no button to switch the language, please make them all in English at night because some of us don't understand , thank you

  5. #5
    Join Date
    Mar 2006
    Posts
    6

    Re: debug error using struct

    I have attached the struct code as an attachment

    The function is declared before calling the function as
    struct vector {double x[Max_DD];int size;};
    struct f {double f[Max_f];int size;};
    struct position {struct vector p;struct f f;};
    struct position PSO(int level, float Max_Eval);

    Kindly help me.
    swaroop
    Attached Files Attached Files

  6. #6
    Join Date
    Feb 2006
    Location
    Chickago
    Posts
    3

    Question Re: debug error using struct

    I think Mattrang was incorrect about struct definition, the implementation and and function declarations for the most part look really ill-formed, sorry I am currently under bad weather. Would you mind posting some other implementation parts of the work you are laying your hands on ? I think it wouldn't be a good idea for us to only guess where the mistake lies with such a little piece of information.
    -Yeu.chi.hai

  7. #7
    Join Date
    Aug 2001
    Location
    Texas
    Posts
    645

    Re: debug error using struct

    Post your whole project - not just portions.

    Include the DSW so that we can rebuild it just like you have done.

  8. #8
    Join Date
    Mar 2006
    Posts
    6

    Re: debug error using struct

    I have attached the whole project.The main file is main.c and the def_struct.c contains all the declarations.The text files functions.txt and problems.txt will feed the necessary parameters for running the program.
    thanx n regards
    swaroop
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured