c++ linux system command
The system
function takes a string. In your case it's using the text *curr_val_str* rather than the contents of that variable. Rather than using sprintf
to just generate the number, use it to generate the entire system command that you require, i.e.
sprintf(command, "echo -n %d > /file.txt", curr_val);
first ensuring that command is large enough.