Answer the question
In order to leave comments, you need to log in
How to parse a string in C?
Good afternoon. There is a format string:
828,2065,2001,1000, True The, "LINESTRING (13.3667747154831 49.6852257801913 49.6858398295424,13.3636960233053 49.6855263919521,13.3627006339596)"
We need to break it into parts between the commas, but ignore everything after True. How can this be done in C language? I tried strtok(), but it fails to ignore the unwanted part of the string.
Answer the question
In order to leave comments, you need to log in
Yes, everything is simple. Cut off everything that comes after the letter "T" (you search through strchr, and trimming is easy to google), then for the rest sequentially (while or for loop) go through each character. If it is not equal to a comma, then add a character to the temporary string (which you can create right there in the loop). Each such line will be the desired numbers.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question