回答編集履歴

1

strtok例を追加

2017/02/01 04:48

投稿

can110
can110

スコア38266

test CHANGED
@@ -9,3 +9,33 @@
9
9
 
10
10
 
11
11
  各関数の使い方は、ArduinoやC言語の入門サイトなどを参考にしてください。
12
+
13
+
14
+
15
+ 以下はstrtokでカンマ毎に文字列を切り出す例です。
16
+
17
+ ```C
18
+
19
+ #include <stdio.h>
20
+
21
+ #include <stdlib.h>
22
+
23
+ int main(void) {
24
+
25
+ char str[] = "123,012";
26
+
27
+ char *tok = strtok( str, "," );
28
+
29
+ while( tok){
30
+
31
+ printf( "%d\n", strtol( tok , NULL, 16));
32
+
33
+ tok = strtok( NULL, "," );
34
+
35
+ }
36
+
37
+ return 0;
38
+
39
+ }
40
+
41
+ ```