Thread: what is the meaning of these warnings..

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

    what is the meaning of these warnings..

    ||=== ff, Debug ===|

    warning: char format, different type arg (arg 2)| //on scanf
    warning: implicit declaration of function `strlen'|
    warning: char format, different type arg (arg 2)| //scanf
    ||=== Build finished: 0 errors,3 warnings ===|

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Quote Originally Posted by transgalactic2 View Post
    warning: char format, different type arg (arg 2)| //on scanf
    The compiler is telling you that you lied to scanf by giving it one type and telling it to expect another.

    Quote Originally Posted by transgalactic2 View Post
    warning: implicit declaration of function `strlen'|
    Probably forgot to #include <string.h>. You used the function without properly declaring it, just like it said. Including the header file would include a declaration of the function.

    Quote Originally Posted by transgalactic2 View Post
    warning: char format, different type arg (arg 2)| //scanf
    See first warning.

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by transgalactic2 View Post
    ||=== ff, Debug ===|

    warning: char format, different type arg (arg 2)| //on scanf
    warning: implicit declaration of function `strlen'|
    warning: char format, different type arg (arg 2)| //scanf
    ||=== Build finished: 0 errors,3 warnings ===|
    It means you called scanf() wrong, and you failed to include <string.h>
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  4. #4
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    scanf("%70s",&f);

    f is declARED as char f[71];

  5. #5
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    And your point?

    %s and friends are expecting a char *. When you pass an array to a function, it decays to a pointer to its first element. This means this would work just fine:

    Code:
    scanf("%70s", f);
    On the other hand, &f is a different type than f. &f is a pointer to an array of 70 chars. That is totally different.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what is the meaning of these warnings?
    By transgalactic2 in forum C Programming
    Replies: 7
    Last Post: 03-08-2009, 10:21 AM
  2. Warnings when using vector of vector
    By Boksha in forum C++ Programming
    Replies: 5
    Last Post: 03-29-2008, 01:54 PM
  3. Replies: 9
    Last Post: 03-14-2008, 09:55 AM
  4. The Meaning of Life: A Trick Question?
    By chix/w/guns in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 07-12-2004, 07:53 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM