Thread: reading command line arguments into buffer

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    4

    reading command line arguments into buffer

    I am now trying to figure out how to read more than 1 command line argument into a buffer that is just one string. Is this possible? Do I have a chance. This is all I have left and then I graduate in 2 weeks. All your help is really appreciated.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You know how to cycle through the command line arguments right? Use a for loop and go until you get to whatever argc is.

    You know how to stick two strings together right? Use strcat or strncat.

    That's all you need.

    Or you could do it this way:
    Code:
    #include<stdio.h>
    int main(int argc
    ,char*argv[]){int
    x;for(x=0;x<argc;
    x++)fprintf(stdout
    ,"%s",argv[x]);
    return 0;}
    Because stdout is buffered. So technicly...

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Dec 2002
    Posts
    4
    I had forgotten about strcat. I got it though. Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading a buffer line by line, while using system read
    By Hammad Saleem in forum C Programming
    Replies: 9
    Last Post: 05-27-2008, 05:41 AM
  2. Reading the data bitween the different headers in a buffer.
    By ariseramesh8 in forum C Programming
    Replies: 1
    Last Post: 04-27-2008, 01:40 AM
  3. Reading in 16 and 24-bit audio data into (32-bit) integer buffers
    By theblindwatchma in forum C Programming
    Replies: 2
    Last Post: 04-13-2008, 11:12 PM
  4. NULL arguments in a shell program
    By gregulator in forum C Programming
    Replies: 4
    Last Post: 04-15-2004, 10:48 AM
  5. getline problem
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 10-06-2001, 09:28 AM