lundi 29 juin 2015

function call using pointers


Can anyone explain me why am I getting the error

cannot convert int ** to int* of argument1

I have seen all the stack overflow answers but did not find the way to solve my problem. My code

#include<stdio.h>

int* sum(int,int*);

int main()
{
    int a=5;
    int *b;

    *b=6;
    int *res;

    res=sum(a,&b);
    printf("\n%d\n%d\n",a,*b);
    printf("%d",*res);
}

int* sum(int x,int *y)
{
    x=x+1;
    *y=*y+3;
    return (&y);
}

This is a basic problem but I am finding it hard to solve the error.


Aucun commentaire:

Enregistrer un commentaire