Access c variable in system command

Sachin Setiya

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");
}
Ferruccio

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);
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

system() command with a variable in Swift

From Dev

Access Delete Command Not Recognizing Variable

From Dev

Proper command execution for Control access in system

From Dev

Access c variable as an array

From Dev

C Structure variable access

From Dev

Binding the result of a system command to a variable in Haskell

From Dev

System Variable path is different in command prompt

From Dev

Binding the result of a system command to a variable in Haskell

From Dev

mkdir system call with variable (C)

From Dev

Access denied on folder System32 using cipher command?

From Dev

Unable to access nmap command via system() function in R

From Dev

Syntax error with system() command to rename a file in C

From Dev

Using scala variable in executing awk system command in scala

From Dev

Use Python variable in bash command with os.system

From Dev

set a variable in jmeter postprocessor and access in command prompt in NON GUI mode

From Dev

set a variable in jmeter postprocessor and access in command prompt in NON GUI mode

From Dev

Copy command line arg to a variable C

From Dev

How to pass variable to shell command in C?

From Dev

Copy command line arg to a variable C

From Dev

How to pass variable to shell command in C?

From Dev

How to set system environment variable in C#?

From Dev

Query = Unknown system variable 'c3'

From Dev

How to access c# variable in javascript in selenium

From Dev

ARM assembly access to C global variable

From Dev

Access a member in a struct via a variable in C++

From Dev

How to access another variable C#

From Dev

Objective-C: Cannot access synthesized variable

From Dev

Access C# variable from in JavaScript

From Dev

Default access modifier for class and variable in C#?

Related Related

  1. 1

    system() command with a variable in Swift

  2. 2

    Access Delete Command Not Recognizing Variable

  3. 3

    Proper command execution for Control access in system

  4. 4

    Access c variable as an array

  5. 5

    C Structure variable access

  6. 6

    Binding the result of a system command to a variable in Haskell

  7. 7

    System Variable path is different in command prompt

  8. 8

    Binding the result of a system command to a variable in Haskell

  9. 9

    mkdir system call with variable (C)

  10. 10

    Access denied on folder System32 using cipher command?

  11. 11

    Unable to access nmap command via system() function in R

  12. 12

    Syntax error with system() command to rename a file in C

  13. 13

    Using scala variable in executing awk system command in scala

  14. 14

    Use Python variable in bash command with os.system

  15. 15

    set a variable in jmeter postprocessor and access in command prompt in NON GUI mode

  16. 16

    set a variable in jmeter postprocessor and access in command prompt in NON GUI mode

  17. 17

    Copy command line arg to a variable C

  18. 18

    How to pass variable to shell command in C?

  19. 19

    Copy command line arg to a variable C

  20. 20

    How to pass variable to shell command in C?

  21. 21

    How to set system environment variable in C#?

  22. 22

    Query = Unknown system variable 'c3'

  23. 23

    How to access c# variable in javascript in selenium

  24. 24

    ARM assembly access to C global variable

  25. 25

    Access a member in a struct via a variable in C++

  26. 26

    How to access another variable C#

  27. 27

    Objective-C: Cannot access synthesized variable

  28. 28

    Access C# variable from in JavaScript

  29. 29

    Default access modifier for class and variable in C#?

HotTag

Archive