有没有办法有一个水桶位指针? (C / C ++) [英] Is there a way to have a bit bucket pointer? (C/C++)

查看:172
本文介绍了有没有办法有一个水桶位指针? (C / C ++)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法有一个水桶位指针?

Is there a way to have a bit bucket pointer?

很多的IO(输入具体相关的)系统调用返回的数据到一个特定大小的缓冲区。有没有窍门或方法,使八九不离十位斗指针,所以我可以接受,将被扔掉任何数量的数据。做这样的事情CHAR TMP [INT_MAX]是疯狂的。我找的行为是一样的东西的/ dev / null的,只有一个指针的世界。

A lot of IO (specifically input related) system calls return data to a buffer of a specific size. Is there a trick or way to make a sorta bit bucket pointer, so I can accept any amount of data that will be thrown away. Doing something like "char tmp[INT_MAX]" is crazy. The behavior I am looking for is something like /dev/null, only in a pointer world.

不要希望在这....只是好奇。

Not to hopeful on this.... just curious.

谢谢,
Chenz

Thanks, Chenz

更新:也许MMAP-ING的/ dev / null的。忘了,当我问这个问题。

UPDATE: Perhaps mmap-ing /dev/null. Forgot about that when I asked the question.

推荐答案

哪些IO接口您使用的?如果是基于文件的方法(FOPEN,FREAD等),你可以继续阅读到相同的缓冲区,而忽略它的内容。您可以在C / C ++做任何事情,所以你想要的东西当然是可能的,但它不是完全清楚你正在尝试做的。也许张贴一些code?

Which IO interface are you using? If it is FILE based methods (fopen, fread, etc) you can just keep reading into the same buffer and ignore its contents. You can do anything in C/C++ so what you want is certainly possible, but it isn't totally clear what you are trying to do. Maybe post some code?

这篇关于有没有办法有一个水桶位指针? (C / C ++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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