F
ferbar
Hi all,
I'm trying to read from the txt file 'ip.packets.2.txt' using the read
function. It seems everything ok, but I get a -1 when executing
The 'open' function returns the file dsc 3. So this seems ok..
Any idea what might be wrong?
Thanks!
FBM
#define BUFSIZE 1024
#include <fcntl.h>
#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
double now() {
struct timeval t;
gettimeofday(&t,NULL);
return ((double)t.tv_sec + (double)t.tv_usec/1000000.0);
}
int main(int argc, char** argv) {
int fdo1;
double t;
char * pathname;
ssize_t bytesr;
void * bufread;
pathname = argv[1];
fdo1 = open("C:/cygwin/home/Jeannie/workspace/hw2/ip.packets.2.txt",
O_RDWR);
t = now();
bytesr = read(fdo1, bufread, 2);
t = now() - t;
printf("time %.3f\n", t);
exit(0);
}
I'm trying to read from the txt file 'ip.packets.2.txt' using the read
function. It seems everything ok, but I get a -1 when executing
The 'open' function returns the file dsc 3. So this seems ok..
Any idea what might be wrong?
Thanks!
FBM
#define BUFSIZE 1024
#include <fcntl.h>
#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
double now() {
struct timeval t;
gettimeofday(&t,NULL);
return ((double)t.tv_sec + (double)t.tv_usec/1000000.0);
}
int main(int argc, char** argv) {
int fdo1;
double t;
char * pathname;
ssize_t bytesr;
void * bufread;
pathname = argv[1];
fdo1 = open("C:/cygwin/home/Jeannie/workspace/hw2/ip.packets.2.txt",
O_RDWR);
t = now();
bytesr = read(fdo1, bufread, 2);
t = now() - t;
printf("time %.3f\n", t);
exit(0);
}