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
    22,304
    Change:
    Code:
    b = pch;
    to:
    Code:
    b = pch != NULL;
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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, 06:55 PM
  2. Looking for constructive criticism
    By wd_kendrick in forum C Programming
    Replies: 16
    Last Post: 05-28-2008, 10:42 AM
  3. assignment makes pointer from integer
    By crescen7 in forum C Programming
    Replies: 4
    Last Post: 06-25-2002, 11:08 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 06:06 PM
  5. Replies: 3
    Last Post: 01-14-2002, 12:13 PM

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