Thread: what this warning means..

  1. #1
    Banned
    Join Date
    Oct 2008
    Posts
    1,535

    what this warning means..

    i defined
    Code:
    char opt[254];
    on this line i get
    |55|warning: char format, different type arg (arg 2)|
    Code:
    scanf("%s",&opt);
    what that means??

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    &opt is not a pointer to char, which you need for the %s format specifier. You should use a pointer to char (in this case, "opt").

  3. #3
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    and as a side note - you should limit a number of chars that could be read by the format - to prevent buffer overrun

    scanf("%253s",opt);
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  4. #4
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    what will happen to the program if the user will enter 254 chars?

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Your head will twist right off your body, and zoom into outer space!!

    Try it and see.

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    The program will format your hard drive, too!
    http://apps.sourceforge.net/mediawik...Buffer_overrun
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  3. Dev-cpp - compiler options
    By tretton in forum C Programming
    Replies: 7
    Last Post: 01-06-2006, 06:20 PM
  4. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM