concatenate char array in C

后端 未结 7 1650
故里飘歌
故里飘歌 2020-12-05 02:15

I have a a char array:

char* name = \"hello\";

I want to add an extension to that name to make it

hello.txt
相关标签:
7条回答
  • 2020-12-05 02:40

    You can concatenate strings by using the sprintf() function. In your case, for example:

    char file[80];
    sprintf(file,"%s%s",name,extension);
    

    And you'll end having the concatenated string in "file".

    0 讨论(0)
提交回复
热议问题