Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个问题,我需要向套接字发送一些数据,数据存储在一个 char 变量中(我们称之为变量 A),但是这个数据中的一些东西正在改变,是否可以插入另一个变量(变量B)在这个变量中并发送变量A以及变量B所做的更改?
变量 B:
char B[] = "inserted by the user"
变量 A:
char A[] = "soemthing '%Variable B' something else"
尝试
char * A = malloc(strlen(B) + 40); /* You can tot up the additional bit here for the rest of A including the null */ sprintf(A, "something '%s' something else", B);