Command Line argument

This is a discussion on Command Line argument within the C Programming forums, part of the General Programming Boards category; Hi all, In the following: #include <stdio.h> main(int argc, char * argv[]) char name[], number[], middle[], fullLine[]; middle="\t 837337 \t ...

  1. #1
    Unregistered
    Guest

    Question Command Line argument

    Hi all,

    In the following:

    #include <stdio.h>

    main(int argc, char * argv[])

    char name[], number[], middle[], fullLine[];
    middle="\t 837337 \t C\t";

    how can I assign argv[1] to name[], argv[2] to number[], and
    concantenate the values of name[], middle[], and number[] (in this order) in fullLine[].

    Since I should preserve the original values of argv[1], argv[2], and middle[] for later use in the program, I should not used the character pointers, I guess (I may be wrong?).

    Your suggestions would be highly appreciated.

    Damar

  2. #2
    Registered User pinko_liberal's Avatar
    Join Date
    Oct 2001
    Posts
    284
    #include <string.h>

    some functions declared in string.h

    char* strcat(char* s, const char* ct);
    Concatenate ct to s and return s.

    char* strcpy(char* s, const char* ct);
    Copies ct to s including terminating NUL and returns s.


    eg., strcpy(name,argv[1]);

    name must be big enough of course

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. member as default argument
    By MarkZWEERS in forum C++ Programming
    Replies: 2
    Last Post: 03-23-2009, 09:09 AM
  2. template argument
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 03-12-2008, 04:01 AM
  3. function passing argument..array ?
    By jochen in forum C Programming
    Replies: 2
    Last Post: 09-30-2007, 12:53 PM
  4. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  5. Nested loop frustration
    By caroundw5h in forum C Programming
    Replies: 14
    Last Post: 03-15-2004, 09:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21