How do I concatenate const/literal strings in C?

前端 未结 17 1490
醉梦人生
醉梦人生 2020-11-21 23:45

I\'m working in C, and I have to concatenate a few things.

Right now I have this:

message = strcat(\"TEXT \", var);

message2 = strcat(strcat(\"TEXT          


        
17条回答
  •  伪装坚强ぢ
    2020-11-22 00:13

    int main()
    {
        char input[100];
        gets(input);
    
        char str[101];
        strcpy(str, " ");
        strcat(str, input);
    
        char *p = str;
    
        while(*p) {
           if(*p == ' ' && isalpha(*(p+1)) != 0)
               printf("%c",*(p+1));
           p++;
        }
    
        return 0;
    }
    

提交回复
热议问题