Question: I can use the following languages, C, Python, or Java. I am using I/O redirection, and I am writing a program to read a series

I can use the following languages, C, Python, or Java.

I am using I/O redirection, and I am writing a program to read a series of names, one per line from standard input, and write out these names spelled in reverse order to standard output. Here are the steps.

a. Input a series of names that are typed in from the keyboard and write them out, reversed, to a file called file1.

b. Read the names in from file1; then write them out, re-reversed, to a file called file2.

c. Read the names in from file2, reverse them again, and then sort the resulting list of reversed words.

I have this so far are file1.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

#include

int main() { /* A nice long string */ char string[256];

printf( "Please enter names in reverse: " );

/* notice stdin being passed in */ fgets ( string, 256, stdin );

printf( "You entered, %s", string );

getchar(); }

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

And this is what I have for file2

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

#include #include #include

FILE *ifp, *ofp;

int main() { char c; int fd; char filename[20];

printf("Enter the name of the file: "); gets(filename); fd = open(filename, O_RDONLY, 0751);

while(read(fd,&c,1) != 0) { write(stdout, &c, 1); } close(fd); } ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

My file2 is asking what file it is going to read, but it won't display the revered names back on the screen. I need help!!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!