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

Graphic software task​

Answers

Answer:

Graphic Designers

ProofHub as Project Management Tool. ProofHub is a versatile project management software for designers. ...

Jira. ...

Kanbanize. ...

Trello as Project Management Software for Graphic Designers. ...

Basecamp as Tool for Project Management. ...

Podio. ...

Asana. ...

Dropbox.

More items...•

Question 2 (10 points)
enables you to view data from a table based on a specific
A-
criterion
Query
Report
Form
All of the above

Answers

Answer: Query

Explanation:

A query simply enables one to view data from a table based on a specific criterion.

We should note that a query is simply referred to as a precise request that is used when retrieving information with the information systems.

When requesting for the data results, and also for the request of some certain action on data, the query is used. If the user wants to perform calculations, answer a particular, make adjustments to w table etc, the query is used.

The virus which activated on a specific data and time is called

Answers

Trojans and other computer viruses that activate on certain dates are often called "time bombs".

What two windows security updates do most organizations always patch?

Answers

Answer:

Explanation:

Patch Tuesday is the name given to the day each month that Microsoft releases security and other patches for their operating systems and other software. Patch Tuesday is always the second Tuesday of each month and more recently is being referred to as Update Tuesday.

Other Questions
Find the measurement of KL (round your answer to the nearest one hundredth. Which theorem did you use? can someone help me? :( Rob is saving to buy a new MP3 player. For every $12 he earns babysitting, he saves $9. On Saturday, Rob earned $36 babysitting. How much money did he save? Which law of thermodynamics? Defines what thermal equilibrium is.2nd1st0th What does a x in the gradebook mean.Will give brainliest Will the sun change its location throughout its development TRUE OR FALSE2 QUESTIONSplease HELP ASAP What are THREE of the biggest challenges that women face today? Please Help Will give all my Brainly points Which statement about +- 3 - 7 = 3 is true?X=-4 is an extraneous solution.X X=-4 is a true solution.x = 4 is an extraneous solutionx = 4 is a true solution.Answer is in the picturee Calculate the puppy's speed at 6 seconds. define liquidity economics. write any six causes to prove that our county is rich in natural resources but back in development In one type of mass spectrometer, ions having the same velocity move through a uniform magnetic field. The spectrometer is being used to distinguish 12C and 14C ions. The 12C ions move in a circle of diameter 45.4 cm. Use these atomic mass values: 12C, 12.0 u; 14C, 14.0 u. Which one should I pick? What is 25=10+w. I need it ASAP ROCKY Elyssa bought a rectangular aquarium . The measurements , in feet (ft) , are shown below. How much water will it take to fill the aquarium? HELP ME PLEASE I DONT GET ITTT Calculate the area of triangles using two different methods. figures are now drawn to scale. What does the sea represent for Ellen and her family? Cite text evidence to support your thinking.