See the lseek_example.c file. Modify the lseek_example.c, such that it reads from an input file (named "start.txt") and will print to an output file (named "end.txt") every (1+3*i)th character, starting from the 1st character in the input file. In other words, it will print the 1st character, then skip 2 characters and print the 4th one, then skip 2 characters and print the 7th one, and so on.
For instance, for input file:
ABCDEFGHIJKLM
It will output:
ADGJM
Iseek_example.c file contant:
// C program to read nth byte of a file and
// copy it to another file using lseek
#include
#include
#include
#include
void func(char arr[], int n)
{
// Open the file for READ only.
int f_read = open("start.txt", O_RDONLY);
// Open the file for WRITE and READ only.
int f_write = open("end.txt", O_WRONLY);
int count = 0;
while (read(f_read, arr, 1))
{
// to write the 1st byte of the input file in
// the output file
if (count < n)
{
// SEEK_CUR specifies that
// the offset provided is relative to the
// current file position
lseek (f_read, n, SEEK_CUR);
write (f_write, arr, 1);
count = n;
}
// After the nth byte (now taking the alternate
// nth byte)
else
{
count = (2*n);
lseek(f_read, count, SEEK_CUR);
write(f_write, arr, 1);
}
}
close(f_write);
close(f_read);
}
// Driver code
int main()
{
char arr[100];
int n;
n = 5;
// Calling for the function
func(arr, n);
return 0;
}

Answers

Answer 1

Answer:

See the lseek_example.c file. Modify the lseek_example.c, such that it reads from an input file (named "start.txt") and will print to an output file (named "end.txt") every (1+3*i)th character, starting from the 1st character in the input file. In other words, it will print the 1st character, then skip 2 characters and print the 4th one, then skip 2 characters and print the 7th one, and so on.

For instance, for input file:

ABCDEFGHIJKLM

It will output:

ADGJM

Iseek_example.c file contant:

// C program to read nth byte of a file and

// copy it to another file using lseek

#include

#include

#include

#include

void func(char arr[], int n)

{

// Open the file for READ only.

int f_read = open("start.txt", O_RDONLY);

// Open the file for WRITE and READ only.

int f_write = open("end.txt", O_WRONLY);

int count = 0;

while (read(f_read, arr, 1))

{

// to write the 1st byte of the input file in

// the output file

if (count < n)

{

// SEEK_CUR specifies that

// the offset provided is relative to the

// current file position

lseek (f_read, n, SEEK_CUR);

write (f_write, arr, 1);

count = n;

}

// After the nth byte (now taking the alternate

// nth byte)

else

{

count = (2*n);

lseek(f_read, count, SEEK_CUR);

write(f_write, arr, 1);

}

}

close(f_write);

close(f_read);

}

// Driver code

int main()

{

char arr[100];

int n;

n = 5;

// Calling for the function

func(arr, n);

return 0;

}

Explanation:


Related Questions

((PLEASE HELP ME)) i need to get all my school work done before thursday
------------- are used to navigate between pages and Web sites.

Question 1 options:

Transitions


Animations


Hyperlinks


None of the above

Answers

Answer:

none of the above

Explanation:

Web navigation refers to the process of navigating a network of information resources in the World Wide Web, which is organized as hypertext or hypermedia. The user interface that is used to do so is called a web browser.

A video game character can face toward one of four directions: north, south, east, and west. Each direction is stored in memory as a sequence of four bits. A new version of the game is created in which the character can face toward one of eight directions, adding northwest, northeast, southwest, and southeast to the original four possibilities. Which of the following statements is true about how the eight directions must be stored in memory?
A. Four bits are not enough to store the eight directions. Five bits are needed for the new version of the game.
B. Four bits are enough to store the eight directions
C. Four bits are not enough to store the eight directions. Sodeen bits are needed for the new version of the game.
D. Four bits are not enough to store the eight directions. Eight bits are needed for the new version of the game.

Answers

Answer:

B. Four bits are enough to store the eight directions

Explanation:

The summary of the question is to determine whether 4 bits can store 8 directions or not.

To understand this question properly, the 8 bits will be seen as 8 different characters.

In computer memory, a computer of n bits can store 2^n characters.

In this case:

[tex]n = 4[/tex] i.e. 4 bits

So:

[tex]2^n = 2^4[/tex]

[tex]2^n = 16[/tex]

This implies that the memory can store up to 16 characters.

Because 16 > 8, then (b) answers the question.

Your co-worker who went to UCLA tells you that DHCP is not enabled at your new job, so you should just use the same IP address that you have at home to connect to the internet. He told you it should work because your computer is communicating with a unique public IP address at home, so no other computer in the world would have it. When you try this, your computer does not have internet access. Give two reasons why?

Answers

Answer:

1. internet connection is not enabled on the computer.

2. The DHCP server in the company is not enabled as well.

Explanation:

For a user to access the internet, the computer must have a public IP address that is either assigned to it by a service provider or dynamically from the DHCP server in the computer. In the case of the former, the user just needs to enable the internet connection to obtain the unique IP address.

If the DHCP server or the internet connection is not enabled, the user would not have access to the internet.

how can we achieve an effective communication with other people​

Answers

Just be yourself!
Explanation.......

Consider any tasks performed in real life, for example, driving a taxi. The task you pick involves many functions. Driving a taxi involves picking up customers, and quickly and safely transporting them to their destination. Go through the components of the AI cycle to automate the problem you choose. List the useful precepts available. Describe how you will represent your knowledge. Based on that, describe how you will use reasoning to make and execute a plan expected to achieve a goal or obtain maximum utility. (this is for artificial intelligence, but they did not have that option)​

Answers

The taxi came at night so you go

Which statement about the Weather Bar in the Outlook calendar is true?

A.It displays weather for the current location for five days.
B.It does not require an internet connection to update.
C.Additional cities can be added for travel needs.
D.It sends pop-up alerts about severe weather.

Answers

Answer:

C

Explanation:

Fyroff consultants, a leading software consulting firm in the United States, decides to launch an Enterprise Resource Planning (ERP) solution. The company chooses the brand name Fyroff Enterprise for the new solution. However, when the company attempts to register the domain name, it finds that a small unknown firm is already registered under the same domain name. The small firm is now attempting to sell the domain name to Fyroff. Which of the following terms refers to this practice of buying a domain name only to sell it for big bucks?
a. cybersquatting
b. logic bombing
c. cyberbullying
d. bot herding
e. cyberstalking

Answers

Answer:

The correct answer is a. cybersquatting

Explanation:

Cybersquatting is the registration of a domain name that corresponds to the denomination of a brand or name, with the main objective of obtaining some economic benefit from its sale to the owner and legitimate owner of the brand. Cybersquatting can range from making money by parking domains (buying names that are then "parked", that is, left unused but generating advertising revenue based on the visits they receive) to redirecting users to another website In order for it to get more traffic, that is, with cybersquatting it is generally intended to sell the registered domain names to the legitimate owners or interested parties, at a price well above the cost of registration or also to use the domain taking advantage of the recognition associated with the legitimate owner to obtain commercial advantages, as clients in the network.

Which option in a Task element within Outlook indicates that the task is scheduled and will be completed on a later
date?
O Waiting on someone else
O In Progress
O Not started
O Deferred

Answers

I think it’s in progress

Answer: D: Deferred

Explanation:

took test

NO LINKS OR I WILL DELETE YOUR FORTNITE ACCOUNT
What can you do with the free version of the splice editor

Answers

Answer:

can i have ur fortnite account if u hav one and dont use it :) i only say that cuz u mentioned fortnite

Explanation:

with the free version you can add effects (cheap effects) cut the video, crop some parts. and posting leaves a watermark until u buy money

Answer:

It has a 7 day free trial while your using the free version

Explanation:

Under which menu option of a word processing program does a star appear?
A star appears under the
menu of the word processing program.

Answers

UNDER THE MENU OPTION INSERT.

Answer:

shapes

Explanation:

Plato got it correctly

please help me faster plzzz
correct plzz​

Answers

Answer:

a. A numeric keypad.

b. An interpreter.

c. A 3D printer.

d. A speaker.

Explanation:

An output device can be defined as a hardware device that typically receives processed data from the central processing unit (CPU) and converts these data into information that can be used by the end user of a computer system.

Also, an input device can be defined as any device that is typically used for sending data to a computer system.

Generally, all of the output and input device of a computer are known as peripheral (external) devices and they provide data (informations) to the end users in various formats such as video, audio, texts, images etc.

Since output and input devices are peripheral (external) devices, they can be connected to the computer system wirelessly or through a wired-connection (cable).

Some examples of peripheral (external) devices are monitor, speakers, keyboard, printer, mouse, scanner, projector etc.

Basically, the three (3) key element of a computer system are: a set of memory modules, processor and a set of input-output (I/O) modules. Each of the input-output (I/O) module interfaces to the central switch or system bus and are used to control one or more peripheral (external) devices.

a. A numeric keypad is a device used to input a PIN. It comprises of numbers ranging from 0 to 9.

b. An interpreter analyses and executes a program line by line.

c. A 3D printer produces output in the form of solid objects. It is typically used for inscribing or printing textual informations or graphic images on an object in three dimensions.

d. A speaker produces output in the form of sound. It is an electronic device that converts electrical signals into sound energy (waves).

Other Questions
How was Franklin D. Roosevelt a lasting impact even on today's society I GIVE BRAINLIEST FOR EXPLANATION AND CORRECT ANSWER EXTRA POINTS If the graph of the function moves to the right two units what is the new vertex of the function URGENT, PLEASE ANSWERR If someone who is 5 feet tall uses a potato gun to shoot a potato in the air at 100 feet per second, we can use the function ()=162+100+5 to calculate how far the potato will be from the ground at any given second (t). What does the h(0) represent in the context of the problem? Which option in a Task element within Outlook indicates that the task is scheduled and will be completed on a laterdate?O Waiting on someone elseO In ProgressO Not startedO Deferred The radius of the base of a metallic rod is 2 centimeters, and its height is 24 centimeters. What is the volume of this cylinder? A. 96pi cm B. 92pi cm C. 84pi cm D. 98pi cm A drawer contains unmatched socks. There are 7 black, 4 blue, and 5 white. What is the probability that you will select a white sock, not replace it, and then draw another white sock without looking?0.10=10%0.098=9.8%0.078=7.8%0.08.=8.3% Show your work: 1/2x = 10 WILL MARK BRAINLIEST A group of friends had dinner at a restaurant. The total bill for the dinner was $41 and they left a 15% tip. What was the total amount that they paid? standard deviation of the data. 160,220,220,249,190 A coordinate grid has a scale of 1unit = 100 miles. How far apart, inmiles, are points (-3, 2) and (-3,12)? What do the h and k in the equations of a circle represent? A separatory funnel contains the two immiscible liquids water and toluene. Use the given densities to determine which layer is on top and which is on the bottom in the binary mixture. Solvent Density (g/mL) toluene 0.87 water 0.998 Drag and drop each label into the box to indicate the position of the liquid in the mixture. Top layer Bottom layer 2) How do you think the United States government and American people should have responded to Nazism and their treatment of Jewish people? 11. Combine the following pairs of sentences using the connectors given againsteach pair : 4(a) (i) I shall not talk to you.(ii) You apol o gize for what you did.( unless )(b) (i) He put on his best suit.(ii) He wanted to make a strong im pres sion.( be cause )(c) (i) He was proud of his new car.(ii) It was painted bright yel low.( which )(d) (i) Her cu les served a king.(ii) The king sent him on diffi cult er rands again and again.( who ) Expand and combine like terms: (2x^3+4x^5)^2= Why Africa is very poor continent though it is very rich in natural resources? On the Moon's surface, lunar astronauts placed a corner reflector, off which a laser beam is periodically reflected. The distance to the Moon is calculated from the round-trip time. The Earth's atmosphere slows down light. Assume the distance to the Moon is precisely 3.84108 m, and Earth's atmosphere (which varies in density with altitude) is equivalent to a layer 30.0 km thick with a constant index of refraction n=1.000293. What is the difference in travel time for light that travels only through space to the moon and back and light that travels through the atmosphere and space? 1. Calculate the scale factor.a. b. c. 2 d. 32. Find the value of x.a. 30m b. 35 c. 45 d. 60