Thread: Frustrating Error Message!!! (for a function)

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    12

    Frustrating Error Message!!! (for a function)

    Code:
    #include<stdio.h>
    double marks [20][2];
    double averageMark (double marks[20][2], int numMarks);
    #define LIMIT 100
    void main()
    {
    	int i=0;
    	int count=0;
    	double marks[20][2];
    	int numMarks;
    	double average;
    
    	printf("\nPlease enter the mark (-ive to end entry): ");	
    	scanf("%lf", &marks[i][0]);
    	if (marks[i][0] > LIMIT)
    	{
    		printf("\nPlease enter only numbers between 0 and 100");
    		printf("\nPlease enter the mark (-ive to end entry): ");	
    			scanf("%lf", &marks[i][0]);
    	}
    
    	while (i < 20 && marks[i][0] >= 0)
    	{
    		i++;
    
    		printf("\nPlease enter the mark (-ive to end entry): ");
    			scanf("%lf", &marks[i][0]);
    		if (marks[i][0] > LIMIT)
    		{
    		printf("\nPlease enter only numbers between 0 and 100");
    		printf("\nPlease enter the mark (-ive to end entry): ");	
    			scanf("%lf", &marks[i][0]);
    		}
    
    	}
    
    	count = i;
    	i--;
    	numMarks = count;
    
    		printf("\nYou've entered %d marks", numMarks);
    
    		average = averageMark (marks, numMarks); 
    		
    		
    		getchar();
    
    	
    }
    
    double averageMark (double marks[][1],int num)
    {
    	double totalofmarks = 0.0;
    	double average;
    	int i=0;
    	while (i < (num-1) || i == (num-1))
    	{
    		totalofmarks += marks[i][0];
    		i++;
    	}
    	return(totalofmarks/num);
    
    }
    I keep getting an error message that reads: 1>Lab7_Lab8_Arrays_Sorting.obj : error LNK2019: unresolved external symbol "double __cdecl averageMark(double (* const)[2],int)" (?averageMark@@YANQAY01NH@Z) referenced in function _main
    1>C:\Users\Andrew\Documents\Visual Studio 2005\Projects\Assign_6Arrays\Debug\Assign_6Arrays. exe : fatal error LNK1120: 1 unresolved externals

    Any help would be greatly appreciated...

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Code:
    double averageMark (double marks[20][2], int numMarks);
    double averageMark (double marks[][1],int num)
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by Holtzy View Post
    Code:
    double averageMark (double marks[20][2], int numMarks);
    
    double averageMark (double marks[][1],int num)
    You've got to pick one: either averageMark takes a 20 by 2 array, or an x by 1 array.

  4. #4
    Registered User
    Join Date
    Mar 2008
    Posts
    12

    Error Message

    Thanks very much for the help. It worked without a hitch. I was going crazy there!!!

    Best of luck!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM