Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help on concatenate argv[]

Status
Not open for further replies.

cxnoel

Programmer
Nov 19, 2001
6
CA
Hi. I am not a C programmer but I need to complete my little C program which will run on Unix (HP-UX). I need to take all passed arguments into a single string and get its length.
Arguments may look like this:

Uranus 3100 This is a test;0;0;Group A;Group B

The first 2 arguments must stay as argv[1] and argv[2] but the remaining of the line must be inserted into a single string and get is caracter count.

So, what I did up to now is this:

main(argc, argv)
int argc;
char *argv[];
{
int i;
int nbr;
char *ret;
for (i = 3; i < argc; i++)
{
ret = strcat(ret,argv);
}
nbr = sizeof(ret);
}

Can someone tell me what's wrong? (As I said, I am far from being a C specialist; I am a VB specialist and I didn't use C since 10 years!).

Thanks for your help.
 
main(argc, argv)
int argc;
char *argv[];
{
int i;
int nbr;
char ret[128];
*ret = 0;
for (i = 3; i < argc; i++)
{
strcat(ret,argv
Code:
[i]
);

}
nbr = strlen(ret);
}


matt
 
YES! You're a PRO !

Thank you very much.

Claude
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top