Pointers: Warning C4028

This is a discussion on Pointers: Warning C4028 within the C Programming forums, part of the General Programming Boards category; Good morning! Though my l'il program seems to be working just fine, I get this warning when compiling from the ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    18

    Question Pointers: Warning C4028

    Good morning!
    Though my l'il program seems to be working just fine, I get this warning when compiling from the command line:

    "Warning C4028:formal parameter 1 different from declaration"
    Header file:
    Code:
    #ifndef GRADES_H
    #define GRADES_H
    
    	float calcAssignment (void);
    	float calcExam (void);
    	float calcTotal (float, float);
    	void  displayInfo (char* name);
    	void studentName(char* name);
    	void grades (void);
    
    	typedef struct {
    
    	char name[50];
    	int assignment[100];
    	int exam[100];
    
    } StudentGrades;
    
    StudentGrades student = {0};
    
    #endif
    Source:
    Code:
    void grades (void)
    
    {
    	
    	char firstlast[BUFSIZ] = {0};
    
    	DEBUG_PRINT("Entering grades function ");
    
        studentName(firstlast); 
    	displayInfo(firstlast);
    
    
    }
    
    void studentName(StudentGrades *student)//<<<-------- warning!!
    {
    
    	DEBUG_PRINT("Entering studentName function ");
    
    	printf	("\n\nPlease enter student's name:");	
    	scanf	( "%[^'\n']", student ->name );
    
    }
    
    
    void displayInfo (StudentGrades *student)// <<<------------  warning!!
    ...
    (shortened for brevity...)
    What is causing this? Do I need more coffee? Golly it's late!

  2. #2
    Disrupting the universe Mad_guy's Avatar
    Join Date
    Jun 2005
    Posts
    258
    In the header file they're defined as using char* parameters, yet in the implementation they're defined as using the type StudentGrades.


    Switch one or the other and it'll work.
    operating systems: mac os 10.6, debian 5.0, windows 7
    editor: back to emacs because it's more awesomer!!
    version control: git

    website: http://0xff.ath.cx/~as/

  3. #3
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Code:
    void studentName(char* name);
    Code:
    void studentName(StudentGrades *student)
    Notice the difference in the function declarations? Well your compiler notices the difference too, and it doesn't like it.

  4. #4
    Registered User
    Join Date
    Oct 2005
    Posts
    18
    Wonderful - thank you so much, I wasn't even looking at the friggin' header...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pointers, structures, and malloc
    By lugnut in forum C Programming
    Replies: 24
    Last Post: 10-09-2008, 04:52 PM
  2. Unreachable code?
    By Leojeen in forum C Programming
    Replies: 15
    Last Post: 09-28-2008, 07:11 PM
  3. Errors
    By Rhidian in forum C Programming
    Replies: 10
    Last Post: 04-04-2005, 12:22 PM
  4. <regex.h> help needed! C slower than Java
    By bobk544 in forum C Programming
    Replies: 9
    Last Post: 02-06-2005, 05:03 AM
  5. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 08:32 AM

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