I am trying to return the value of a shell script. From what I have read it looks like i can use popen, but for some reason I can not get the code to work. Right now when I run the code I get garbage characters and not the float I am wanting.
The value form the shell script is a float.
I want to return the value of a bash script so I can use the returned value from the shell scrip as variables for my C code.
#include <stdio.h>
//Settings Variables
float upload_speed;
float download_speed;
int main(int argc, char **argv)
{
FILE *upload_speed;
//Runs shell script on code and returns data
upload_speed = popen("./Filter_Data.sh Upload", "r");
printf("return value is: %s", upload_speed);
return 0;
}
<mysql/mysql.h>? Why do you have global variables (that are unused)? Have you ever done anything with files in C (e.g. usingfopen,fread,fgets, etc)?gcc -Wall -Wextra -pedantic -O2.