开发者

Getting a substring in C

开发者 https://www.devze.com 2023-01-20 10:32 出处:网络
I have a string in the following format: \"R:625.5m E:-32768m\" What\'s the most efficient开发者_如何转开发 way to pull out the 625.5?Your best bet is to use sscanf to read formatted information from

I have a string in the following format: "R: 625.5m E:-32768m"

What's the most efficient开发者_如何转开发 way to pull out the 625.5?


Your best bet is to use sscanf to read formatted information from the string.

sscanf(mystr, "R: %f", &myFloat);


sscanf is a good candiate to parse simple strings with fixed format.

0

精彩评论

暂无评论...
验证码 换一张
取 消