Error] cannot convert 'float**' to 'float*' for argument '1' to 'void fill(float*, in

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nicrochaos
    New Member
    • May 2015
    • 2

    Error] cannot convert 'float**' to 'float*' for argument '1' to 'void fill(float*, in

    #include<stdio. h>

    void fill(float *av,int *max,int *i,FILE *p,int n)
    {
    while(!feof(p))
    {
    *av+=n;
    if(*max<n)
    *max=n;
    (*i)++;
    }
    *av=(n)/(*i);
    fclose(p);
    }


    the call is{
    p=fopen(fn,"r") ;
    fill(&av,&max,& i,p,n);
    fclose(p);
    }
    the message in the description keeps popping up.I tried changing almost everything, but nothing seems to work.i'd really appreciate it if you show me your guidance,for i'm a total beginner, started a month ago!!
    Last edited by nicrochaos; May 1 '15, 08:08 AM. Reason: too long
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #2
    Please show us the definitions (types) for the variables being passed to fill when you call it.

    Comment

    • donbock
      Recognized Expert Top Contributor
      • Mar 2008
      • 2427

      #3
      My guess is av is defined as an array of floats. If so, then...
      • function1(av[0]) passes a single float value.
      • function2(av) passes a single float* value that points at the first element in the array.
      • function3(&av[2]) passes a single float* value that points at the third element in the array.
      • function4(&av) passes a single float** value that points to a pointer to the first element in the array.


      float* is a pointer to a float variable.
      float** is a pointer to a variable which in turn is a pointer to a float variable.

      Click on the Articles tab and then look at the entry named Arrays Revealed for a much more complete explanation. (I can't seem to embed a link today.)

      Comment

      • nicrochaos
        New Member
        • May 2015
        • 2

        #4
        solved it
        turned out that the declaration was wrong,float *av
        led to the float** issue, though i didn't know what the ** was about at first,so thanks for opening my eyes on the subject.
        i really appreciate it.

        Comment

        Working...