Results 1 to 2 of 2

Thread: int argc, char *argv[]

  1. #1

    Thread Starter
    Addicted Member bataeu's Avatar
    Join Date
    Nov 2000
    Location
    Walla Walla, Washington
    Posts
    144

    int argc, char *argv[]

    I am trying to take paramiters from the command line but everytime i compile this it tells me
    error C2061: syntax error : identifier 'argc'
    I dont know if i need to be including a header to get the argc and argv thing to work but i searched around the forums and it looks like no one else is so i dont know. Thanks for any help.
    C, C++ and none of that MCF crap either!

  2. #2
    jim mcnamara
    Guest
    Code:
    #include <stdio.h>
    int main(int argc,char *argv[]){
             int i;
             i=1;
             while(i<=argc) printf("Parameter #%d %s\n",i,argv[i++]);
             return 0;
    }
    You should not have to include anything, I included stdio.h because of printf().

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width