I want to use output of a callback function on another system command. but not working on it, can anybody help?----
#include <stdio.h>
#include <stdlib.h>
int fastLine(const char *filename);
int main() {
char* ip_file = "f1";
fastLine(ip_file); // to print callback
// want to use it on system command,, but not working
system("ping fastLine(ip_file)");
return 0;
}
////// 1st line of file callback function ////////
int fastLine(const char *filename) {
char line[1000];
FILE *fptr;
if ((fptr = fopen(filename, "r")) == NULL) {
printf("Error! opening file");
// Program exits if file pointer returns NULL.
exit(1);
}
// reads text until newline is encountered
fscanf(fptr, "%[^\n]", line);
printf("%s\n", line);
fclose(fptr);
return 0;
}