P
Peter Rothenbuecher
Hello,
when I try to compile the following code:
/* This fragment of code is taken from an online tutorial */
#include<stdio.h>
#include<fcntl.h>
#include<stdlib.h>
float bigbuff[1000];
main(int argc, char **argv)
{ int fd;
int bytes_read;
int file_length;
if ( (fd = open(argv[1],O_RDONLY)) = -1)
{ /* error file not open */
perror("Datafile");
exit(1);
}
if ( (bytes_read = read(fd,&file_length,
sizeof(int))) == -1)
{ /* error reading file */
exit(1);
}
if ( file_length > 999 ) {/* file too big */ }
if ( (bytes_read = read(fd,bigbuff,
file_length*sizeof(float))) == -1)
{ /* error reading open */
exit(1);
}
}
I get this error message:
test.c: In function `int main(int, char**)':
test.c:24: error: `read' undeclared (first use this function)
test.c:24: error: (Each undeclared identifier is reported only once for
each function it appears in.)
I have seen, that the function read() isn´t defined in <stdio.h>. Does
anybody can help me? Do you know, if there is defined a function read()
anywhere with the prototype
"int read(int handle, char *buffer, unsigned length)"
and can tell me.
Thanks a lot, if you could help me.
Peter
when I try to compile the following code:
/* This fragment of code is taken from an online tutorial */
#include<stdio.h>
#include<fcntl.h>
#include<stdlib.h>
float bigbuff[1000];
main(int argc, char **argv)
{ int fd;
int bytes_read;
int file_length;
if ( (fd = open(argv[1],O_RDONLY)) = -1)
{ /* error file not open */
perror("Datafile");
exit(1);
}
if ( (bytes_read = read(fd,&file_length,
sizeof(int))) == -1)
{ /* error reading file */
exit(1);
}
if ( file_length > 999 ) {/* file too big */ }
if ( (bytes_read = read(fd,bigbuff,
file_length*sizeof(float))) == -1)
{ /* error reading open */
exit(1);
}
}
I get this error message:
test.c: In function `int main(int, char**)':
test.c:24: error: `read' undeclared (first use this function)
test.c:24: error: (Each undeclared identifier is reported only once for
each function it appears in.)
I have seen, that the function read() isn´t defined in <stdio.h>. Does
anybody can help me? Do you know, if there is defined a function read()
anywhere with the prototype
"int read(int handle, char *buffer, unsigned length)"
and can tell me.
Thanks a lot, if you could help me.
Peter