underfined reference to usernotes????

This is a discussion on underfined reference to usernotes???? within the C Programming forums, part of the General Programming Boards category; Code: I'm trying to set up a matrix where user inputs first line...I can't see why this doesn't work. Can ...

  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    13

    underfined reference to usernotes????

    Code:
    I'm trying to set up a matrix where user inputs first line...I can't see why this doesn't work. Can anybody tell me?
    
    
    #include<stdio.h>
    
    int usernotes(int P[][12], int); //is this not the defined function??
    
    
    int main(){
    	
    
      int i,j,temp;
    
    
      int P[12][12];
    
      //Initialize array to -1 rather than 0
      for(i=0;i<12;i++) P[0][i] = -1;
       
    
      printf("Please enter 12 notes hitting enter after each one.\n");
      for(i=0;i<12;i++) P[0][i] = usernotes(P,i);
    }
    Last edited by jaquenta; 12-10-2008 at 07:48 AM.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So where is the usernotes function defined?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    This is a function prototype:
    Code:
    int usernotes(int P[][12], int);
    This is a function definition:
    Code:
    int usernotes(int P[][12], int) {
                    [...do stuff...]
    }
    You must have at least the second one. The purpose of the prototype is for when you have a number of funcitions that may reference one another, making it impossible to put them into "the order of use". If there are prototypes at the top, the compiler will accept all the functions regardless of where the definition is in the program. But your program does not have a definition for usernotes() at all!
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #4
    Registered User
    Join Date
    Dec 2008
    Posts
    13
    cool that help cheers
    Last edited by jaquenta; 12-10-2008 at 07:54 AM.

  5. #5
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    The function usernotes() is missing!!! You've declared it, so therefore, the compiler expects to see it defined somewhere.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You are asking the code to call a function called "usernotes", but in the code you have posted, there is no definition of what that function does. The compiler will need to have that SOMEWHERE - if it's because you haven't written it, then you need to write it. If you (or someone else) have written it, but it's in a different file, then you need to tell the compiler that there is another file that is required to be compiled.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

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, 09:18 PM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 12:45 PM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  4. C OpenGL Compiler Error?
    By Matt3000 in forum C Programming
    Replies: 12
    Last Post: 07-07-2006, 05:42 PM
  5. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM

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