Reading in file extension from user input

Currently I have.

char *baseDir=".\\*."

what I want to do it be able to take a user input of variable length and add it to the end of the char.  I've tried strcpy and couple other ways.  Even tried reading in the users input as a char and just doig a for loop to add to the end.  I would appreciate any help.

Who is Participating?
DanRollinsConnect With a Mentor Commented:

you need a buffer, and not just a pointer to the existing string literal:

char szBuf[200];

strcpy( szBuf, baseDir );
strcat( szBuf, szNewInputFromUser );

now szBuff will contain the original value plus the input.

-- Dan
lightspdAuthor Commented:
Thanks worked great.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.