Click here to Skip to main content
15,884,472 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: concat two char * variables [modified] Pin
santhosh-padamatinti20-Jan-10 20:13
santhosh-padamatinti20-Jan-10 20:13 
GeneralRe: concat two char * variables Pin
CPallini20-Jan-10 21:20
mveCPallini20-Jan-10 21:20 
GeneralRe: concat two char * variables Pin
Saravanan Sundaresan21-Jan-10 18:52
professionalSaravanan Sundaresan21-Jan-10 18:52 
AnswerRe: concat two char * variables Pin
Avi Berger20-Jan-10 7:11
Avi Berger20-Jan-10 7:11 
AnswerRe: concat two char * variables Pin
David Crow20-Jan-10 7:53
David Crow20-Jan-10 7:53 
GeneralRe: concat two char * variables Pin
Richard MacCutchan20-Jan-10 11:50
mveRichard MacCutchan20-Jan-10 11:50 
GeneralRe: concat two char * variables Pin
Fatbuddha 120-Jan-10 20:13
Fatbuddha 120-Jan-10 20:13 
GeneralRe: concat two char * variables Pin
CPallini20-Jan-10 20:51
mveCPallini20-Jan-10 20:51 
Why wondering?
It is concise and elegant, functionally equivalent to strcat, here the complete function
char * concat( char * c1, const char * c2)
{
  char *c3 = c1;

  while (*c3)
    c3++;

  while (*c3++ = *c2++)
    ;
  return c1;
}


here a test program:
#include <stdio.h>
void main()
{
  char buf[100];
  sprintf(buf, "hello");
  char * str = " folks!";
  printf("%s\n", concat(buf, str));
}


He just missed the const reuqirement for the first argument. But this is an OP fault (i.e. David's prototype is better).
Smile | :)

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke

[My articles]

GeneralRe: concat two char * variables Pin
Richard MacCutchan20-Jan-10 22:14
mveRichard MacCutchan20-Jan-10 22:14 
QuestionRe: concat two char * variables Pin
CPallini20-Jan-10 22:19
mveCPallini20-Jan-10 22:19 
AnswerRe: concat two char * variables Pin
Richard MacCutchan20-Jan-10 23:15
mveRichard MacCutchan20-Jan-10 23:15 
GeneralRe: concat two char * variables Pin
CPallini20-Jan-10 23:29
mveCPallini20-Jan-10 23:29 
GeneralRe: concat two char * variables Pin
Richard MacCutchan20-Jan-10 23:36
mveRichard MacCutchan20-Jan-10 23:36 
QuestionModal vs Modeless dialog box Pin
msr_codeproject20-Jan-10 6:05
msr_codeproject20-Jan-10 6:05 
AnswerRe: Modal vs Modeless dialog box Pin
Richard MacCutchan20-Jan-10 6:08
mveRichard MacCutchan20-Jan-10 6:08 
AnswerRe: Modal vs Modeless dialog box Pin
Rajesh R Subramanian20-Jan-10 6:58
professionalRajesh R Subramanian20-Jan-10 6:58 
QuestionRaeding and parsing mails via POP3 Pin
VictorSotnikov20-Jan-10 4:52
VictorSotnikov20-Jan-10 4:52 
AnswerRe: Raeding and parsing mails via POP3 Pin
Richard MacCutchan20-Jan-10 5:47
mveRichard MacCutchan20-Jan-10 5:47 
AnswerRe: Raeding and parsing mails via POP3 Pin
Joe Woodbury20-Jan-10 9:48
professionalJoe Woodbury20-Jan-10 9:48 
AnswerRe: Raeding and parsing mails via POP3 Pin
Rozis20-Jan-10 14:06
Rozis20-Jan-10 14:06 
Questionproblem with stack structure implementation in C, plz help !!! Pin
hung2h20-Jan-10 3:14
hung2h20-Jan-10 3:14 
AnswerRe: problem with stack structure implementation in C, plz help !!! Pin
Richard MacCutchan20-Jan-10 3:38
mveRichard MacCutchan20-Jan-10 3:38 
GeneralRe: problem with stack structure implementation in C, plz help !!! Pin
hung2h20-Jan-10 3:52
hung2h20-Jan-10 3:52 
GeneralRe: problem with stack structure implementation in C, plz help !!! Pin
hung2h20-Jan-10 4:07
hung2h20-Jan-10 4:07 
GeneralRe: problem with stack structure implementation in C, plz help !!! Pin
Tim Craig20-Jan-10 12:45
Tim Craig20-Jan-10 12:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.