double array in function

This is a discussion on double array in function within the C Programming forums, part of the General Programming Boards category; Hello I would like some info of how to it. I have a double array which I read the data ...

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    79

    double array in function

    Hello I would like some info of how to it.

    I have a double array which I read the data from a file in the main. What I want is to use the contents of this array in a function and return the result to main


    Code:
     #include
     .... ........ 
    function(what to write?)  
     main()  { 
     double **array 
     allocate space
     scan file 
    have the data into the array
      something=function( )  
     } 
     
    
    
    function(what to write?)
     { 
    declare variables.....  
     for (i=0;i<=num_of_forces;i++)   
      {
    for (j=0;j<=num_of_genes;j++) 	
    { 	
      a=a+(array[i][j]);    	
    }    
    return a;   
     } 
    }

  2. #2
    Registered User GL.Sam's Avatar
    Join Date
    Aug 2009
    Posts
    88
    Technically speaking, this
    >double **array
    is not a real two-dimensional array, it just behaves like that giving proper memory allocations. So,
    >function(what to write?)
    would look like
    double function(double **array, size_t num_of_forces, size_t num_of_genes)


    >for (i=0;i<=num_of_forces;i++)
    >for (j=0;j<=num_of_genes;j++)
    Furthermore, you want to use `<' in general array indexes processing, not `<='.
    The only good is knowledge and the only evil is ignorance.
    ~Socrates

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling C in Visual Studio 2005
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-16-2009, 04:25 AM
  2. Functions, have errors...NEED HELP FAST
    By alkamenes in forum C++ Programming
    Replies: 6
    Last Post: 11-02-2009, 03:00 PM
  3. Need some help...
    By darkconvoy in forum C Programming
    Replies: 32
    Last Post: 04-29-2008, 04:33 PM
  4. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  5. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 10:54 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21