Question
Write a program in C that does the following: 1. It doesn't use a call from any C or C++ library including cout, cin, printf,
Write a program in C that does the following:
1. It doesn't use a call from any C or C++ library including cout, cin, printf, scanf, etc. Instead, it uses system calls such as open(), close(), read(), write(), and lseek().
2. It takes a file as input. It then reads the file from top to bottom and bottom to top simultaneously.
3. If a character being read in the first part is the same as a character being read in the second part, a 0 is printed out. Else, a 1 is printed out.
4. Then for each pair of differing characters, it prints out the position number of the first character, the differing characters, and a new line.
5. Finally, it prints out the number of character positions that differ.
For example, suppose the input file has the text "abcdefdcbx"
Then the following is printed out:
100011001
1 a x
5 e f
6 f e
10 x a
Total: 4 character positions differ
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started