Hello,
I'm trying to open a Linux shell script which searches a document for a particular number.
I would like to get this number into a variable for use in my C-program so I can test it.
I use popen and the correct number is displayed by my C program, but I cannot seem to do anything with it. For instance I am unable to get the correct value into another function.
What's going on here? Thanks for any help
OJ
Code:
int main ( )
{
while (1){
char buff[BUFSIZ];
FILE *fp = popen( ". getfile", "r" );
while ( fgets( buff, BUFSIZ, fp ) != NULL ) {
}
pclose( fp );
printf("variable buff is: %s\n",buff);
//This displays "10" which is correct
use_info (*buff);
}
return 0;
}
int use_info (int var) {
printf("Values passed to function is %d\n", var);
//This displays "49" which is incorrect
}