用vprintf()过滤 [英] Filtering with vprintf()

查看:70
本文介绍了用vprintf()过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用vprintf()过滤掉某些行.我要打印很多,因为这是组装好的包装的数据部分.我只想要内容类型的部分.这不起作用,有任何建议吗?
谢谢

I''m trying to filter out a certain line with vprintf(). I''m getting alot of print out being this is the data part of an assembled packet. I just want the content-type part. This doesn''t work, Any suggestions?
Thanks

vprintf("%c", data[i], "Content-Type: application/x-www-form-urlencoded""");

推荐答案

此功能并非旨在过滤"任何东西.它将格式化的变量参数列表打印到标准输出.参见:
http://www.cplusplus.com/reference/clibrary/cstdio/vprintf/ [ ^ ],
http://www.cplusplus.com/reference/clibrary/cstdarg/va_list/ [ ^ ].

我不知道您尝试使用代码示例中显示的调用参数来实现什么.它无法从数据中过滤出内容类型(或任何内容).如果您仍需要在此问题上提供帮助,则应解释数据中的内容以及您希望从这些数据中得到什么.

—SA
This function is not designed to "filter" anything. It prints formatted variable argument list to standard output. See:
http://www.cplusplus.com/reference/clibrary/cstdio/vprintf/[^],
http://www.cplusplus.com/reference/clibrary/cstdarg/va_list/[^].

I have no idea what you tried to achieve using the call parameters shown in the code sample. It could not filter out the content-type (or anything at all) from data. If you still need to help on this matter, you should explain what''s in data and what do you want to get out of this data.

—SA


也许您正在寻找类似 string :: find ,在字符串中搜索内容键入"part".
Perhaps you are looking for something like strstr or string::find, to search the string for the "Content Type" part.


就像Dalek Dave所说的那样,FFS!

As Dalek Dave would say, FFS!

char *origStr =  "Content-Type: application/x-www-form-urlencoded";
char *searchStr = "Content-Type: ";
char *desiredExerpt, *contentTypeTagPtr;

contentTypeTagPtr = strstr(origStr, searchStr);
desiredExerpt = contentTypeTagPtr + strlen(searchStr);

printf(desiredExerpt);


这篇关于用vprintf()过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆