warning: assignment makes integer from pointer without a cast

This is a discussion on warning: assignment makes integer from pointer without a cast within the C Programming forums, part of the General Programming Boards category; Here is the code I wrote to detect whether a LAN cable is pluged or unpluged. After compilation, it gives ...

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

    warning: assignment makes integer from pointer without a cast

    Here is the code I wrote to detect whether a LAN cable is pluged or unpluged. After compilation, it gives me the warning:

    Code:
    warning: assignment makes integer from pointer without a cast
    Here is my code:

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    #define yes 1
    #define no 0
    typedef int boolean; 
    
    int main()
    {
      FILE *fp;
      char *pch;
      char line[130];			/* line of easa!from unix command*/
      int m;
      boolean b;
       
      fp = popen("nm-tool | grep Link", "r");		/* Issue the command.		*/
    
    					/* Read a line			*/
      while ( fgets( line, sizeof line, fp))
      {
        printf("%s", line);
      }
      pclose(fp);
    
      pch = strtok (line," 	");
      for (m=0; m<2; m++)
      {
        pch = strtok (NULL, " 	");
      }
        printf ("%s\n",pch);
      b = pch;
      printf("%d\n",b);		/* more to add on */
    
      return 0;
    }

    I have googled some solutions online, like include the stdlib.h header and etc but all didn't work. Does anyone has any idea on it?

    Thanks in advance.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,618
    Change:
    Code:
    b = pch;
    to:
    Code:
    b = pch != NULL;
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Link List math
    By t014y in forum C Programming
    Replies: 17
    Last Post: 02-20-2009, 05:55 PM
  2. Looking for constructive criticism
    By wd_kendrick in forum C Programming
    Replies: 16
    Last Post: 05-28-2008, 09:42 AM
  3. assignment makes pointer from integer
    By crescen7 in forum C Programming
    Replies: 4
    Last Post: 06-25-2002, 10:08 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 3
    Last Post: 01-14-2002, 11:13 AM

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