2019/05/11

C 使用strtok切割字串


#include <iostream>
#pragma warning( disable : 4996 )

int main()
{
 char str[1024] = "121454.00,A,2237.79779,N,12035.89901,E,0.489,,100519,,,A*71";
 char* c;
 c = strtok(str, ",");
 while (c != NULL) {
  printf("%s\n", c);
  c = strtok(NULL, ",");
 }
}


參考資料:
https://dotblogs.com.tw/thkaw/2013/12/11/133462
https://blog.wu-boy.com/2010/04/cc-%E5%88%87%E5%89%B2%E5%AD%97%E4%B8%B2%E5%87%BD%E6%95%B8%EF%BC%9Astrtok-network-mac-address-%E5%88%86%E5%89%B2/

沒有留言:

張貼留言