I am current writing a program that will find words in a file and replace those words with other words
eg. find dog replace it with cat.
I can open a file fine with (o_fd=open(av[1], O_RDWR))== -1) if blah blah.
But i was wondering after opening the file, when it reaches the reading state how would i input each of the characters into an array so i could have a while loop to go through the array of characters and if this matches does this does that.
I have this code to test if its reading in the file characters.Code:while((n_chars=read(in_fd, buf, BUFFERSIZE))>0) { if (n_chars!= 0) { printf("Read'%d' bytes\n", n_chars); } }
I have a char a[Arraysize] declared. I just need to know if i can read the file characters into an array and how to do this.
- Brez