关于读数据流的问题
来源: 互联网 发布时间:2015-11-28
本文导语: 我想通过流的方式读一个音频数据的文件的数据 使用read函数是,那个buff的指针类型应该是什么 | #include #include #include #include #include #include int main(void) { void *buf; int handle, ...
我想通过流的方式读一个音频数据的文件的数据
使用read函数是,那个buff的指针类型应该是什么
使用read函数是,那个buff的指针类型应该是什么
|
#include
#include
#include
#include
#include
#include
int main(void)
{
void *buf;
int handle, bytes;
buf = malloc(10);
/*
Looks for a file in the current directory named TEST.$$$ and attempts to read 10 bytes from it. To use this example you should create the file TEST.$$$.
*/
if ((handle =
open("TEST.$$$", O_RDONLY | O_BINARY, S_IWRITE | S_IREAD)) == -1)
{
printf("Error Opening Filen");
exit(1);
}
if ((bytes = read(handle, buf, 10)) == -1) {
printf("Read Failed.n");
exit(1);
}
else {
printf("Read: %d bytes read.n", bytes);
}
return 0;
}
#include
#include
#include
#include
#include
int main(void)
{
void *buf;
int handle, bytes;
buf = malloc(10);
/*
Looks for a file in the current directory named TEST.$$$ and attempts to read 10 bytes from it. To use this example you should create the file TEST.$$$.
*/
if ((handle =
open("TEST.$$$", O_RDONLY | O_BINARY, S_IWRITE | S_IREAD)) == -1)
{
printf("Error Opening Filen");
exit(1);
}
if ((bytes = read(handle, buf, 10)) == -1) {
printf("Read Failed.n");
exit(1);
}
else {
printf("Read: %d bytes read.n", bytes);
}
return 0;
}