L
loudking
Dear all,
I am writing a client-server application and the client should upload
a file to the server, then the server should display the content of
the file in stdout.
Because I have to deal with binary files, I cannot use character
strings, so I chose integer array instead.
But the problem is that how can I display them in stdout? I tried "%c"
and "%d", but neither will work.
Client side:
int fdin;
int *up_file;
struct stat buf;
fdin = open(file, O_RDONLY);
fstat(fdin, &buf);
up_file = (int *)malloc(buf.st_size * sizeof(int));
up_file = mmap(0, buf.st_size, PROT_READ, MAP_SHARED, fdin, 0)
Server Side:
for (int i = 0; i < iarray_len; i++)
printf("%d", iarray_val);
The uploading procedure will be handled by Sun RPC.
Thanks!
I am writing a client-server application and the client should upload
a file to the server, then the server should display the content of
the file in stdout.
Because I have to deal with binary files, I cannot use character
strings, so I chose integer array instead.
But the problem is that how can I display them in stdout? I tried "%c"
and "%d", but neither will work.
Client side:
int fdin;
int *up_file;
struct stat buf;
fdin = open(file, O_RDONLY);
fstat(fdin, &buf);
up_file = (int *)malloc(buf.st_size * sizeof(int));
up_file = mmap(0, buf.st_size, PROT_READ, MAP_SHARED, fdin, 0)
Server Side:
for (int i = 0; i < iarray_len; i++)
printf("%d", iarray_val);
The uploading procedure will be handled by Sun RPC.
Thanks!