this is the message i got after building-undefined reference to 'scanf'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mike89
    New Member
    • May 2013
    • 1

    this is the message i got after building-undefined reference to 'scanf'

    hi!
    i wrote this program in c and this is the line that the code blocks gave me when i did build to the program. i couldn't understand what is the problem and this is why i'm looking for help from you all... thank you, i need to submit the project on sunday...

    Code:
    #include <stdio.h>
    #define N 20
    #define M 20
    int main()
    
    {
    int x,y,j,k,w,inner,numrow,clmnum,matrix[N][M],mtrxsum,minmtrx;
      printf("Enter num of rows (up to 20 rows) \n");
      scanf("%d",&numrow);
      printf("Enter num of columns (up to 20)\n");
      scnaf("%d",&clmnum);
      printf("enter matrix of size %dX%d, row after row :\n",numrow,clmnum);
      for (x=0;x<numrow;x++)
    {
        for (y=0;y<clmnum;y++)
        scanf("%d",&matrix[x][y]);
        mtrxsum+=matrix[x][y];
    }
    if (numrow>clmnum)
    inner=(clmnum-1)/2;
    else
    inner=(numrow-1)/2;
    for (w=0;w<inner;w++)
    {
     minmtrx=0;
     for (j=1;j<(numrow-1);j++)
    {
         for(k=1;k<(clmnum-1);k++)
         minmtrx+= matrix [j] [k];
    if ((mtrxsum-minmtrx)-minmtrx==0)
    printf("min width of requested perimeter is : %d",w);
    printf("The sum of its elements is : %d",minmtrx);
    }
    printf("Not found such a perimeter_width");
    }
      return 0;
    }
    Last edited by Rabbit; May 31 '13, 04:47 PM. Reason: Please use code tags when posting code.
  • Oralloy
    Recognized Expert Contributor
    • Jun 2010
    • 988

    #2
    Hello mike89,

    First off, in the future can you please use CODE tags to block your code? Looking at C source that has been HTMLized is painful. This is the BB CODE reference.

    That said, have you read FAQ?

    Now, in retrospect, I looked at your code and found this:
    Code:
    scnaf("%d",&clmnum);
    Which is perfectly acceptable C code, because of the implicit function declaration rules.

    I don't know what IDE you are using, or if you are using raw text files; however the first thing I recommend to all beginning software developers is that they eliminate ALL warnings from their code before trying to run it.

    One tool you might find useful (assuming you are running under Linux, or have a copy on your windows box) is lint. When you write code that it does not complain about, you are well on your way to completing your work.

    Kind Regards,
    Oralloy
    Last edited by Oralloy; May 31 '13, 03:54 PM. Reason: Added salutation

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Is scanf really misspelled?

      Comment

      Working...