I want to pass a float array from one function to another function
I want to make use of the float array type(here container)

void funct1()
{
float container[4]={0.1,0.2,0.3,0.4}

void funct2()         ----(1)
{return container;}


}

void funct3()
{

void funct2();

use container array;

}void funct1()
{
float container[4]={0.1,0.2,0.3,0.4}

void funct2()         ----(1)
{return container;}


}

void funct3()
{

void funct2();

use container array;

}

Here what would be the funct2() like

void funct2(container) ----(1)

void funct2(float container[]) ---(2)

use container array

Recommended Answers

All 2 Replies

Thats one lot of mess, you should start indenting your code properly and perhaps what happened to your code tags. You will have to put your question properly in order to get more help. From what u have said i have come up with the sample code which will give you an idea on what need to be done

#include <stdio.h>
#define MAXSIZ    5

void PrintFloat(double []);

int main( void )
{
    double num[MAXSIZ] = { 12.23, 23.42, 45.66, 67.897, 786.86 };
    
    PrintFloat(num);
    
    getchar();
    return 0;
}

void PrintFloat(double num[])
{
     int i;
     
     for(i = 0; i < MAXSIZ; i++)
         printf("%.3f\t", num[i]);
}     

/* my output
12.230  23.420  45.660  67.897  786.860
*/

Dont define the function within the function. Its not a good programming practice, and perhaps u will have function scope problems which is just a mess.

ssharish

>Dont define the function within the function.
>Its not a good programming practice
Yep, it's not a good programming practice because nested functions are illegal in C. I wouldn't call a practice that completely fails to compile anything but bad. ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.