Hello everyone I am still new to c but going throught a book called Learn c on the mac but I am using Ubuntu. I wrote a easy little program in witch it will ping all ip addresses from 192.168.6.1 to 192.168.6.254 once and print the responce out. I am getting "/usr/include/stdio.h:870:14: note: expected ‘const char *’ but argument is of type ‘int’" but I can't figure out why becuase I get the error on this line.
Code:
fp = popen(ping, 'r');
but they are declared like this
Code:
char ping[30];
FILE *fp;
here is the whole thing.
Code:
#include <stdio.h>
#include <stdlib.h>
main(){
int count = 0;
char ping[30];
FILE *fp;
char op[200];
while( count = 1, count <= 254, count++)
{
sprintf(ping, "ping -c 1 192.168.6.%d", count);
fp = popen(ping, 'r');
while (fgets(op, sizeof(op)-1, fp) != NULL)
{
printf("%s", op);
}
}
return 0;
}
I have been seraching the internet but I am still unable to figure out why I am getting this, anyone have an idea?
Thank you to anyone who replies.