Thread: Functions and pointers

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    71

    Functions and pointers

    hey guys.

    i have to write a difficult program to take student grades and compute them. i am defedently going to need more help on this later. the one problem i am having right now that i cant seem to figure out is that my compiler is saying "syntax error before int" it says this on the line in my program that says processOneStudent(int*numStudentPtr........) it is in main. can you just help me figure out why it is saying that??? here is my code. dont make fun its not even close to finish yet.

    Code:
    #include <stdio.h>
    
    void welcome(void);
    void processOneStudent(int *numStudentsPtr, int *studentIdPtr, int *yearPtr, int *cumulativeHoursPtr, float *cumulativeGPAPtr);
    void reportStudentData(int studentId, int class, int cumulativeHours, float cumulativeGPA);
    int applyCriteria(void);
    void reportSummary(void);
    char more_students;
    
    int main(){
    
        welcome();
        printf("More Students (Y or N):\t");
        scanf("%c", &more_students);
        
        if(more_students=='Y'||'y'){
        
        processOneStudent(int *numStudentsPtr, int *studentIdPtr, int *yearPtr, int *cumulativeHoursPtr, float *cumulativeGPAPtr);
                                    
        else if(more_students=='N'||'n')
    
        }
    
    system ("pause");
    return 0;
    }
        
    void welcome(void){
         printf("\n%s%s%s%s\n",
         "***********************************************\n\n",
         "*   Welcome to the Academic Standing System   *\n\n",
         "*           Developed by Drem Darios          *\n\n",
         "***********************************************\n");
         
         }
         
    void processOneStudent(int *numStudentsPtr, int *studentIdPtr, int *yearPtr, int *cumulativeHoursPtr, float *cumulativeGPAPtr ){
                           
                           int hours;
                           int grade;
                           
                           printf("Enter student id, class, cum. hours, cum. GPA:\t");
                           scanf("%d%d%d%f", &studentIdPtr, &yearPtr, &cumulativeHoursPtr, &cumulativeGPAPtr);
                           
                           
                           printf("Hours and grade (0 0 to end)?\t"); 
                           scanf("%d%d", &hours, &grade);
                           while ( hours<0 && grade<0){
                           
                           printf("Hours and grade (0 0 to end)?\t"); 
                           scanf("%d%d", &hours, &grade);
                           
                           }
                           
    
                           }
    
    void reportStudentData(int studentId, int year, int cumulativeHours, float cumulativeGPA){
                           
                           printf("Student Id:\t%d\n", studentId);
                           printf("Class:\t%d\n", year);
                           printf("New Cumulative Hours:\t%d\n", cumulativeHours);
                           printf("New Cumulative GPA:\t%.2f\n", cumulativeGPA);                      
                           
                           }
    
    
    void reportSummary(int numStudents, int numInGoodStanding){
         printf("Number of Students:\t%d\n", numStudents);
         printf("Number in Good Standings\t%d\n",numInGoodStanding);
         printf("\nThank you for using the Academic Standing System. Bye bye!");
         }

  2. #2
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,732
    Code:
     processOneStudent(int *numStudentsPtr, int *studentIdPtr, int *yearPtr, int *cumulativeHoursPtr, float *cumulativeGPAPtr);
    When you are calling the function u dont need to specify the datatypes of those arguments. You have already done at that before, which is there on top of the main. When you call the function u will have to just pass the parameters to that function, like as follow

    Code:
     processOneStudent(numStudentsPtr, studentIdPtr, yearPtr, cumulativeHoursPtr, cumulativeGPAPtr);
    And you need a proper code indendation. And there are lots of syntac error which i can find on your code. I can see that you wanted to send the numStudentsPtr, stuentIdPtr, CumulativeHoursPtr and cumulativeGPAPtr as a pass by referece to function processOneStudent. But i dont see any where that you have declared those variables. And perhaps if you are sending them through pass by reference you will have to put a '&' simple in front of those arguments when calling processOneStudent, to specify the compile to send the address of those variable but not the values of those variables.

    ssharish

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Conversion of pointers to functions
    By hzmonte in forum C Programming
    Replies: 0
    Last Post: 01-20-2009, 01:56 AM
  2. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  3. Passing pointers between functions
    By heygirls_uk in forum C Programming
    Replies: 5
    Last Post: 01-09-2004, 06:58 PM
  4. API "Clean Up" Functions & delete Pointers :: Winsock
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 05-10-2002, 06:53 PM
  5. pointers, functions, parameters
    By sballew in forum C Programming
    Replies: 3
    Last Post: 11-11-2001, 10:33 PM