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.
udpクライアントサーバーを使用してサーバーにデータセンサーを送信したい。
printf("sensor 0 '%s' \n",buf0); printf("sensor 1 '%s' \n",buf1);
たとえば、buf0の値は1023で、buf1の値は0です。センサー0:1023をバッファー(buffなど)にマージしたい
サーバーにバフを送ることができます。
そしてサーバーは受け取ります
"sensor 0 :1023" "sensor 1 : 0"
何か暗示?
snprintfを使用できます
snprintf(buf, 100, "sensor 0 : %s", buf0);
ここで、bufはタイプですchar buf[100];
char buf[100];
これ:
char buf[128]; snprintf(buf, sizeof(buf), "sensor 0: '%s'\n", buf0);
等