Here is the code I wrote to detect whether a LAN cable is pluged or unpluged. After compilation, it gives me the warning:
Here is my code:Code:warning: assignment makes integer from pointer without a cast
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.



LinkBack URL
About LinkBacks


