StringCchCat don't work at the first time

Hi,someone could explain to me why this code
1
2
3
4
5
6
7
  for (i=3;i<argc-1;i++) 
   {
 
   StringCchCat(argv[2],MAX_PATH,TEXT("-")); 
   StringCchCat(argv[2],MAX_PATH,argv[i]); 

   }


whit this input: myprogram cartel s s s

output this s--s and not what i expected that is s-s-s
i'm getting crazy...
Thank you
Last edited on
argv should be considered const. You should not be appending to it.
You are right!
but why it don't work only the first time?


SOLUTION

1
2
3
4
5
6
7
8
9
10
11
12
    StringCchCopy(goal, MAX_PATH, argv[2]);
   
   for (i=3;i<argc-1;i++) 
   {
 
   StringCchCat(goal,MAX_PATH,TEXT(" ")); 
   StringCchCat(goal,MAX_PATH,argv[i]); 

   }
 
   
    _tprintf(TEXT("The goal  is find  %s\n\n"), goal);


Topic archived. No new replies allowed.