0

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.

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Samran
0

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

0

Thanks John A.

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

Thanks again.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.