Hi all,
I ve been given an assignment to be done in LINUX which requires filing for processes.

I have studied about the functions to be used, open, read, write. I have copied the example from the book in my text editor and it gives error when compiled. The input file is named file.in

The code is supposed to copy file.in to file.out, character by character.

Here is the code which I copied from the book

#include  <unistd.h>
#include  <sys/stat.h>
#include  <fcntl.h>
#include  <stdlib.h>

int main()
{
    char c;
    int in, out;
    in = open(“file.in”, O_RDONLY);
    out = open(“file.out”, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR);
    while(read(in,&c,1) == 1)
         write(out,&c,1);
    exit(0);
}

The errorssss I get when compiling are

samran@ubuntu:~/programming/process_filing$ gcc prog.c -o prog
prog.c: In function ‘main’:
prog.c:10: error: stray ‘\342’ in program
prog.c:10: error: stray ‘\200’ in program
prog.c:10: error: stray ‘\234’ in program
prog.c:10: error: ‘file’ undeclared (first use in this function)
prog.c:10: error: (Each undeclared identifier is reported only once
prog.c:10: error: for each function it appears in.)
prog.c:10: error: stray ‘\342’ in program
prog.c:10: error: stray ‘\200’ in program
prog.c:10: error: stray ‘\235’ in program
prog.c:11: error: stray ‘\342’ in program
prog.c:11: error: stray ‘\200’ in program
prog.c:11: error: stray ‘\234’ in program
prog.c:11: error: stray ‘\342’ in program
prog.c:11: error: stray ‘\200’ in program
prog.c:11: error: stray ‘\235’ in program
samran@ubuntu:~/programming/process_filing$

Please help me by solving the errors above and guide me using filing for processes.

Thanks.

You've got smart quotes instead of straight quotes " . Did you write that code in a word processor?

Thanks John A.

Actually I copied and pasted the code from the pdf book. The quotes had the problem.

Thanks again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.