I have the following program:
Code:
#include "ten.h"
int main(int argc, char **argv)
{
off_t offset;
int counter, bytes;
char c;
if (argc != 3) {
fprintf(stderr,"Usage: %s [file1] [file2]\n", argv[0]);
exit(1);
}
if ( (openfiles(argv[1], argv[2])) == -1)
exit(1);
if ( (offset = lseek(files->fdin, offset, SEEK_END)) == -1) {
perror("lseek in main 1");
exit(1);
}
printf("%d\n", (int)offset);
/*counter holds each printable digit.
for (counter = 0; counter < MAX; ++counter) {
*/
return 0;
}
#include "ten.h"
filedes *files;
int
openfiles(char *infile, char *outfile)
{
if ( (files->fdin = open(infile, O_RDONLY)) == -1){
perror("open in openfiles 1");
return -1;
}
if ( (files->fdout = open(outfile, O_WRONLY)) == -1) {
perror("open in openfiles 2");
return -1;
}
return 1;
}
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#define MAX 10
int openfiles(char *, char *);
typedef struct {
int fdin;
int fdout;
} filedes;
typedef enum {
OUT, IN
} iorout;
extern filedes* files;
I think there's a problem with the line: fd->fdin but I'm not sure how to fix it.