Thread: Unable to access/modify desired pointer value after calling a library function

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2014
    Posts
    364
    Thats a good example for using desciptive names for variables and defines.
    Line 2:
    Code:
        int i, j, k,m,n,M;
    M is defined as an integer, but not inizialized.


    Line 8+9:
    Code:
        double v[M*M];
        double d[M];
    v and d are defined as double vectors with a size of M, but M isn't initialized.
    Nobody knows how big or small this vectors are.


    Line 104+105:
    Code:
    #define M 3
        double Gyration[M*M] = {
    …
    M is now a define to represent 3.
    And Gyration is a double vector in size of 9.
    But have v and d the right size?


    To fix this, set line 104 as the first line (in front of the function).
    Delete the integer M on line 2.
    To avoid confusion, rename M to SIZE_M. It makes it clear that this is a defined name.
    Last edited by WoodSTokk; 07-10-2016 at 02:20 PM.
    Other have classes, we are class

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trying to modify array in a shared library function
    By JulietBoy in forum C Programming
    Replies: 8
    Last Post: 05-24-2013, 05:39 AM
  2. Replies: 3
    Last Post: 03-14-2013, 03:25 PM
  3. Replies: 7
    Last Post: 01-12-2013, 05:07 PM
  4. unable to access structure within a function
    By bluetxxth in forum C Programming
    Replies: 7
    Last Post: 02-17-2010, 03:52 AM
  5. Calling C function from dynamically loaded library
    By polas in forum Linux Programming
    Replies: 17
    Last Post: 09-02-2009, 01:04 PM

Tags for this Thread