This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

a-pointer-about-argv

By: a guest on Apr 28th, 2012  |  syntax: C  |  size: 0.64 KB  |  views: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <stdio.h>
  2.  
  3. void init_arg1(int* argc, char **argv[]){
  4.   int i=0;
  5.   for (i=0; i<*argc; i++){
  6.     printf("arg[%d]: %s\n", i, (*argv)[i]);
  7.   }
  8. }
  9.  
  10. void init_arg2(int* argc, char *argv[]){
  11.   int i=0;
  12.   for (i=0; i<*argc; i++){
  13.     printf("arg[%d]: %s\n", i, argv[i]);
  14.   }
  15. }
  16.  
  17. void init_arg3(int argc, char *argv[]){
  18.   int i=0;
  19.   for (i=0; i<argc; i++){
  20.     printf("argv[%d]: %s\n", i, argv[i]);
  21.   }
  22. }
  23.  
  24. int main(int argc, char * argv[]){
  25.  
  26.   printf("----First----\n");
  27.   init_arg1(&argc, &argv);
  28.  
  29.   printf("----Second---\n");
  30.   init_arg2(&argc,  argv);
  31.  
  32.   printf("----Third----\n");
  33.   init_arg3( argc,  argv);
  34.  
  35.   return 0;
  36. }
clone this paste RAW Paste Data