What does string + int perform in C?

后端 未结 3 670
栀梦
栀梦 2021-01-05 07:43

I can\'t figure out this expression:

str + n

where char str[STRING_LENGTH] and int n.

I have worked a lot

3条回答
  •  长情又很酷
    2021-01-05 08:28

    Yes ans of @Yu Hao and @Bathsheba are correct.
    But if you want to do the concatenation, you can go as following code snippet.

    char string[]="hello";
    int number=4;
    char cated_string[SIZE_CATED_STRING];
    sprintf(cated_string,"%s%d",string,number);
    printf("%s",cated_string);
    

    Happy Coding.

提交回复
热议问题