[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

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.

Cheers.
0
lightspd
Asked:
lightspd
1 Solution
 
DanRollinsCommented:

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
0
 
lightspdAuthor Commented:
Thanks worked great.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now