Question: Write a program to read all the characters (at most 1000) from an input file named a.txt. The program should replace every space character by

Write a program to read all the characters (at most 1000) from an input file named a.txt. The program should replace every space character by the last character of the input file.

Note: You program must only read the input file one time.

For example, if the content of the input file a.txt is:

So far the variables we had in our programs were simple variables. There are other kinds of variables and are called structured variables.

Array variables are of this kind@

The output should be:

So@far@the@variables@we@had@in@our@programs were@simple@variables.@There@are@other@kinds@of variables@and@are@called@structured@variables. Array@variables@are@of@this@kind@

Note: This is just a sample example. The last character of the file a.txt could be any printable character.

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!