问题
hello I've got text file with lines format
1|few ewf ew fewfew
I need to parse it but I don't know how can I drop whitespaces tail from second value I don't know.
Here is my segmentation fault
try so far
char* token1;
char* token2;
char* search = "|";
char* search2 = " "; // double space because string can contains single space
while (fgets(line, 150, f)) {
token1 = strtok(line, search);
token2 = strtok(search, search2); // <- segfault
//token2 = strtok(NULL, search); <- contains a lot of spaces in tail
回答1:
Take a gander at the deblank
function. Here's a link: http://www.mathworks.com/help/matlab/ref/deblank.html
来源:https://stackoverflow.com/questions/12582955/remove-whitespaces-tail-from-string-char