使用 strtok() 函數要注意,這個函數會改變第一個參數的內容 - yanbin's Blog
使用 strtok() 函數要注意,這個函數會改變第一個參數的內容
yanbin
posted @ 2015年3月15日 23:59
in Programming
, 1473 阅读
char *strtok(char *str, const char *delim);
token = strtok(str, "\t "); # 算是安裝要操作的 string; str 指向這個 string;
while (token != NULL)
token = strtok(NULL, "\t "); # 每次操作都會改變第一此安裝的 string 的內容.
0. 第一次安裝後,delim 是可以改變的。
1. 如果在調用 strtok() 後還要正常使用 string 以及她的內容,應該在調用 strtok() 前,
調用 strdup() 複製一份 string 的內容;
用複製的 string 註冊 strtok();
char *dupstr = strdup(str);
token = strtok(dupstr, "\t ");
//...
free(dupstr); // str 指向的內容還在。
2022年8月26日 12:01
To learn the most recent details regarding the Maharashtra Board HSC Important Model Question Paper 2023, candidates may read this article. Only for the purpose of the Maharashtra HSC Important Model Question Paper 2023, we have provided the Direct Official Link for each Subject at the bottom of the page. Maha Board 11th Previous Paper 2023 The updated HSC Important Model Question Paper 2023 Maharashtra Board for Class 11th Science, Commerce, and Arts Students has been released by MSBSHE. Mahahsscboard has the Important Model Question Paper for the 11th Board of Maharashtra for 2023 in PDF format.
2022年11月29日 19:15
You will get more details regarding such programming codes from this website. This thread will explain the details marijuana convictions regarding strtok() function. This function is used to change the content of the first parameter. The details are mentioned here and I am looking here to more updates regarding that.
2022年12月20日 10:52
Valgrind is a powerful tool for debugging and profiling Linux programs. It is simple to use, and can be easily integrated into the development process. Valgrind can be used to detect memory leaks, buffer overflows, and other errors. It can also be used to profile programs to CBD vs THC improve performance. Valgrind is an essential tool for developing high-quality Linux programs.