fork(1) download
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <stdarg.h>
  4.  
  5. #define CMD_TAM_MAX (1024)
  6.  
  7. int systemf( const char * fmt, ... )
  8. {
  9. va_list args;
  10. char cmd[ CMD_TAM_MAX + 1 ];
  11.  
  12. va_start( args, fmt );
  13. vsnprintf( cmd, CMD_TAM_MAX + 1, fmt, args );
  14. va_end(args);
  15.  
  16. return system(cmd);
  17. }
  18.  
  19. int main( void )
  20. {
  21. int i = 123;
  22. char ch = 'X';
  23. char * txt = "Ola Mundo!";
  24. float pi = 3.1415f;
  25. double dbl = 1234567890L;
  26.  
  27. systemf( "echo int: %d", i );
  28. systemf( "echo char: %c", ch );
  29. systemf( "echo char*: %s", txt );
  30. systemf( "echo float: %f", pi );
  31. systemf( "echo double: %f", dbl );
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0s 4520KB
stdin
Standard input is empty
stdout
int: 123
char: X
char*: Ola Mundo!
float: 3.141500
double: 1234567890.000000