Thread: Nesting functions which take same pointer as arguments

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    36

    Nesting functions which take same pointer as arguments

    Please open the file code.c in a suitable text editor (like notepad++, to help keep track of the line numbers)

    Line 738: Let us consider the variable R (5th argument in the function MP_modKalMontInv() ). R is passed by reference so the function MP_modKalMontInv() should get an address to R

    Line 565: Inside the function MP_modKalMontInv(), R is further passed into the function MP_monmul_SandK_ver() which is also declared to take address of R (function definition at Line 293)

    Line 310: The address of R is further passed into show_mp_int_fullinfo() but the program now crashes at Line 14 (line 14 is not executed). Why should that happen and what can I do to correct it?

    This program uses the LibTomMath library. R is of type mp_int, which is a structure declared in the LibTomMath library as
    Code:
    typedef struct {
       int used, alloc, sign;
       mp digit *dp;
    } mp int;
    At the menu screen enter 9
    Then enter the following values sequentially when asked
    1
    3333333333
    1
    3333333333
    then press any keys except q at the getch()'s and when the program flow reaches the line described above the program crashes
    I have recreated a similar scenario in the file code.c, however that one doesn't crash.

    Could anyone please give me some idea about this?
    Thank you very much.

    PS: I am using Codeblocks 8.02 with gcc version 3.4.5 (mingw-vista special)
    Attached Files Attached Files
    Last edited by mahaju; 01-29-2012 at 07:39 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 07-28-2011, 06:45 AM
  2. Functions as arguments
    By jw232 in forum C++ Programming
    Replies: 2
    Last Post: 04-19-2008, 11:11 AM
  3. Passing arguments between functions
    By Wiretron in forum C Programming
    Replies: 4
    Last Post: 05-17-2006, 04:59 PM
  4. help with functions using variables as arguments
    By kristentx in forum C++ Programming
    Replies: 2
    Last Post: 03-29-2006, 10:36 AM
  5. functions and pointer arguments
    By Unregistered in forum C++ Programming
    Replies: 6
    Last Post: 01-08-2002, 05:04 PM