Super beginner C programming issue

This is a discussion on Super beginner C programming issue within the C Programming forums, part of the General Programming Boards category; Alright so I barely know what I'm doing, and I see no reason why this isn't working. All it's supposed ...

  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    2

    Question Super beginner C programming issue

    Alright so I barely know what I'm doing, and I see no reason why this isn't working.

    All it's supposed to do is read an integer, and if it's over 100, say it's bigger than 100. If it's not, it'll say it's not bigger. Fairly simple, but I keep getting a warning that says:

    Code:
    lab02pe02.c: In function ‘main’:
    lab02pe02.c:17:5: warning: too many arguments for format [-Wformat-extra-args]
    lab02pe02.c:21:5: warning: too many arguments for format [-Wformat-extra-args]
    Actual C Program:
    Code:
    #include <stdio.h>
    int main( int argc, char *argv[] )
    {
      int x;
      printf( "Enter an integer value:" );
      scanf( "%d", &x );
      if ( x > 100)
    {
        printf( "The number is bigger than 100.\n", x);
      }
      else
    {
        printf( "The number is not bigger than 100.\n", x);
      }
      return 0;
    }
    For my class we have to fill out the "int main(...)" with arguments. Can't just leave it.

    Any suggestions?

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    2,868
    In the next line count the number of variables you are trying to print.
    Next, count the format specifiers (%d, etc.)in the format string.

    Hint: 1 is not equal to 0.

    Tim S.

    Code:
    printf( "The number is bigger than 100.\n", x);
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    Registered User
    Join Date
    Sep 2012
    Posts
    2
    Got it! Thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C Programming help beginner
    By wwrmiw in forum C Programming
    Replies: 8
    Last Post: 03-04-2011, 09:35 AM
  2. C programming beginner
    By rjreynolds in forum C Programming
    Replies: 4
    Last Post: 07-05-2010, 10:33 PM
  3. Super Beginner Question
    By mrfredman in forum C Programming
    Replies: 5
    Last Post: 06-07-2007, 07:26 PM
  4. Replies: 8
    Last Post: 01-17-2006, 05:39 PM
  5. Windows programming for beginner (Absolute beginner)
    By WDT in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2004, 11:21 AM

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