Please just turn in your source code.
----
Some helps:
Open one file for reading - use O_RDONLY as the open flag
Open another file for writing and create it - use O_CREAT , O_EXCL and O_WRONLY
Format for both opens is:
int fd = open(pathname, flags, mode);
example: outp = open("file1.txt",O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IWUSR)
Handle file opening errors. An error opening the file can be detected by finding a -1 in the file descriptor. You can write the error to the screen using write to stdout:
write ( stdout, "There was an error opening file1\n",33);
Then create a variable to hold the character you will read. It should be a char type.
Then read each letter using the read command, to place the character into your variable.
Format for read is:
numRead = read(fd, buffer, count);
example: char buf[20]; int numRead = read(inp,buf,sizeof(buf));
To convert the character to uppercase: use the ctype functions. To access these functions, put #include <ctype.h> at the top of your program. Here is a good tutorial on these functions: http://www.tutorialspoint.com/c_standard_library/ctype_h.htm
if (islower(mychar) != 0) { // this means my character is lowercase
mychar = toupper(mychar); } // change my char to upper and place it back into mychar
You will need to write that character that you changed to the output file:
Format for write is:
numwritten = write(fd, buffer, count);
example: char buf[] = "what I want to write"; int numwritten = write(outp,buf,sizeof(buf));
You want all characters, not just the first, so surround your read and write with a while loop that continues as long as the read is successful. You are expecting one byte to be read, so a return of less than 1 means the file is done. You can make the read itself the while condition so that the program checks the result of the read before continuing through the loop. Be sure to consider what the output of the function is when designing this embedded condition. Ex:
while (numRead = read(inp,buf,sizeof(buf)) > 0){
In this program, you want to end your loop after you write the character.
Handle errors with writing the file with an error message to the screen. You will know there is an error if the numwritten does not match 1, which is the size of the buffer you are writing.
Compile your program using gcc program.c -o program -Wall
Be sure your input file exists in the same folder as the program and has something inside it.
Run your program using ./program
Check to see the output file has the converted characters.