Access c variable in system command
c, system
Solution
You can't do this via any kind of string interpolation such as you've tried. What you need to do is build the command string before passing it to `system()`.
#include <stdio.h>
#include <stdlib.h>
int main() {
int a = 12;
char command[100];
sprintf(command, "echo %d", a);
system(command);
}
Problem
I want to access variable of c in system command but i do not know how to do it i tried like below but this does not works ``` #include<stdlib.h> int main(){ int a=12; system("echo $a"); } ```