回答編集履歴
1
コードの修正を追加
answer
CHANGED
@@ -3,4 +3,13 @@
|
|
3
3
|
sprintf(buf, "%d.%d.%d.%d", suuti1, suuti2, suuti3, suuti4);
|
4
4
|
if (strcmp(src, buf)) return 0;
|
5
5
|
```
|
6
|
-
inet_pton の中の sscanf の次にこのコードを追加するというのはどうでしょうか?
|
6
|
+
inet_pton の中の sscanf の次にこのコードを追加するというのはどうでしょうか?
|
7
|
+
|
8
|
+
**追記**
|
9
|
+
uint8_t へのキャストを付けたほうが、値の範囲チェックもできてよいでしょう。
|
10
|
+
```C
|
11
|
+
char buf[32];
|
12
|
+
sprintf(buf, "%d.%d.%d.%d",
|
13
|
+
(uint8_t)suuti1, (uint8_t)suuti2, (uint8_t)suuti3, (uint8_t)suuti4);
|
14
|
+
if (strcmp(src, buf)) return 0;
|
15
|
+
```
|