Posted By

mwb1100 on 11/05/09


Tagged


Versions (?)

EchoArgs


 / Published in: C
 

Little utility that simply dumps the argv array. Useful for debugging things when you're setting up a tool that shells out to another program - this will tell you exactly how the tool is being invoked.

When I was setting up UltraEdit for calling a cmd script to invoke a compiler, this was essential for figuring out all the stupid little things that were going on in how UE was building the command line.

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4.  
  5. int main( int argc, char** argv)
  6. {
  7. int i = 0;
  8.  
  9. for (i = 0; i < argc; ++i, ++argv) {
  10. if (!(*argv)) {
  11. *argv = "(null)";
  12. }
  13. printf( "arg[%d]: \"%s\"\n", i, *argv);
  14. }
  15.  
  16. return 0;
  17. }

Report this snippet  

You need to login to post a comment.