samedi 25 novembre 2017

I have error to return 2 dimentional array from function

I want to function take the size of array and s then use them and return array but some error in it,please help

#include<iostream>
using namespace std;

float *fun(int s,int size)
{

static float arr[size][size];

arr[0][1] = s;
arr[1][1] = 20;

return arr;
}

int main()
{
    int s=10,h=10;
    float *ptr = fun(s,h);
    cout << ptr[0][1] << " " << ptr[1][1];
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire