Passing Argument-Incompatale Pointer Error

This is a discussion on Passing Argument-Incompatale Pointer Error within the C Programming forums, part of the General Programming Boards category; Hi, i'm trying to run a method i have, but once i compile it gives me the error: "warning: passing ...

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    20

    Passing Argument-Incompatale Pointer Error

    Hi, i'm trying to run a method i have, but once i compile it gives me the error:

    "warning: passing argument 3 of ‚findGrade‚ from incompatible pointer type"

    I have the right parameters for the method though.

    Code:
    int main(Void)
    {
    int answer[100][29];
    int grade[100];
    int miss[100][29];
    int count;
    int two;
    
    count = getInput(answer);
    findGrade(answer, count, grade, miss); <-GIVING ME THE ERROR HERE
    
    }
    
    int getInput(int answer[][TOTAL_QUESTIONS])
    {
    char c;
    int i;
    int j;
    int lines=0;
    
       while(scanf("%c", &c) != EOF)
        {
         if(c != '\n')
          {  
           if (lines <= 75 && j != 29)
            {
             answer[i][j] = atoi(&c); 
              j++;
            }
            else if (j < 29)
             lines++;
          }
          
          else
          i++;
          j=0;
          return lines; 
          //lines=0;   
         }
    
       // for (i=0;scanf("%c", &c);i++)
      //  {
      //   for (j=0; j <= 29; j++)
      //    {
      //   answer[i][j] = atoi(&c); 
      //    }
      //  if(c == '\n')
     //   lines++;
     //   }
       
    
        
    
        
    
    }
    
    void findGrade(int answer[][TOTAL_QUESTIONS], int count, double grade[], int miss[][TOTAL_QUESTIONS]) THE METHOD ITSELF
    {
    int i;
    int j;
       for (i=0; i<=100; i++)
       {
         for (j=0; j<=29; j++)
         {
          if (answer[i][j] != miss[i][j])
           printf("%d",j);
         }
       } 
        count++;
        miss[i][j] = count;
        printf("%d",count);
    }
    Help would be appreciated.

  2. #2
    Registered User
    Join Date
    Feb 2008
    Posts
    20
    oh wait, i figured out the problem. When i made a new local grade array...i made it as an int instead of a double.

  3. #3
    Registered User
    Join Date
    Feb 2008
    Posts
    20
    Aright, i am now at a 3rd method.
    Its where i now retrieve certain parts of a text file, the method is called "outputresult"
    It's goal is to retrieve each of the grades from a text file i got.
    So far, i computed the grade in teh findGrade method and want to retrieve it for outputresult.

    Here's more of my source code, with findGrade but now finished:

    Code:
    void findGrade(int answer[][TOTAL_QUESTIONS], int count, double grade[], int miss[][TOTAL_QUESTIONS])
    {
    int i;
    int j;
    count=0;
    double total=0.00;
       for (i=0; i<=count; i++)
       {
         for (j=0; j<=TOTAL_QUESTIONS; j++)
         {
          if (answer[i][j] == answer[0][j])
          {
           miss[i][j] = 1;
           total = total + 1;
          }
          else
           miss[i][j] = 0;
         }
         grade[i] = (double)total/TOTAL_QUESTIONS * 100;
         
         total = 0; 
       }
        
    }
    
    double findAvg(double grade[],int count)
    {
    int i=0;
    int j=0;
    double total = 0.00;
    count = MAX_STUDENTS;
    
    for(i=1;i < count;i++)
     {           
      total = total + grade[i];
     }
    
    return (double)total/(count-1);
    
    
    }
    
    void printHeading(void)
    {
    printf("Student \t Grade Answer\tWrong Questions\n");
    //printf("Question\tKey\tCorrect perc. Students\tNumber of Responses\n");
    //printf("After Sort:\n");
    //printf("Grade\tFrequency:\n");
    }
    
    void outputResult(int answer[][TOTAL_QUESTIONS], int count, double grade[], int miss[][TOTAL_QUESTIONS])
    {
    int i = 0;
    int j = 0;
    char c;
    
    
      // printf("before loop");
        for(i=1;i<TOTAL_QUESTIONS;i++)
         {
          findGrade(answer, count, grade, miss);
          printf("%f\n", grade[i]);
         }
        
      //  printf("%f",grade);
     
    
    
    }
    When i run it...it just gives me:

    0.00
    0.00
    0.00
    0.00
    0.00
    0.00
    0.00
    0.00
    0.00

    instead of for example:

    38.24
    33.11
    76.55
    44.33
    22.89
    102.45
    etc.

    Help would be appreciated!

  4. #4
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,473
    return (double)total/(count-1);
    If you have 1 student you will finish with divide by zero - get rid of -1

    findGrade
    Why do you need to calculate miss for student 0? Is it the 100 correct always?
    Code:
    for(i=1;i<TOTAL_QUESTIONS;i++)
         {
          findGrade(answer, count, grade, miss);
          printf("&#37;f\n", grade[i]);
         }
    findGrade - calculates results for all students/questions so why to put it inside the loop?

    gradeis number of elements == count+1 so why loop is going upto TOTAL_QUESTIONS?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 03:35 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  5. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 05:45 AM

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