❶ c語言定義宏 #define call(x,y) x##y表示什麼
c語言中,##表示把兩個宏參數貼合在一起,即,
#define call(x,y) x##y ,執行call(x,y)結果為xy,例如,
int x=2,y=5;
int xy=90;
printf("%d\n",call(x,y));//結果為90
##被稱為連接符,用來將兩個宏參數連接為一個宏參數。
而單個#的功能是將其後面的宏參數進行字元串化操作,簡單地說就是在對它所引用的宏變數通過替換後在其左右各加上一個雙引號,使其成為字元串。
❷ 求解一個c語言的字元串問題
代碼文本:
#include "stdio.h"
#include <string.h>
int main(int argc,char *argv[]){
char a[600],b[50],c[50],t[600],*pt;
printf("Please enter 3 strings... ");
scanf("%500s%49s%49s",a,b,c);
while(pt=strstr(a,b)){
strcpy(t,pt+strlen(b));
strcat(strcpy(pt,c),t);
}
printf("The result is: %s ",a);
return 0;
}