开发者

Parsing char array in C++

I'm coding a httpser开发者_开发技巧ver and I'm stuck at parsing GET requests. How would I parse a char buffer with something like

GET /images/logo.png HTTP/1.1

So that I only get the path and file extension but ignore the other parts?


You don't say specifically say what sort of storage this string is in - simple char* or some string class.

So, in general, you could either do it the rather simple and dirty way, by splitting the string on the space character, and taking the second or middle section. Or, a better approach would be to get familiar with Regular Expressions. C++ has several regex libraries - Boost is well regarded.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜