1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
vladimir1956 [14]
3 years ago
6

See the lseek_example.c file. Modify the lseek_example.c, such that it reads from an input file (named "start.txt") and will pri

nt 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;
}
Computers and Technology
1 answer:
andre [41]3 years ago
3 0

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:

You might be interested in
What is the only language a microprocessor can process directly but most programmers almost never write programs in this code? Q
elixir [45]
A microprocessor can directly process machine code but most programmers almost never write in it.
C. Machine code
7 0
3 years ago
Read 2 more answers
The ________ stage of a project involves such activities as forming a team, allocating resources, preparing project documentatio
marysya [2.9K]

Answer:

b. organizing

Explanation:

In the organising stage of a program life cycle involves such activities as forming a team, allocating resources, preparing project documentation, and ensuring good communication.

The organising stage can also comprise of the following activities;

1) To properly Organise and prepare a project.

2) Typically it involves conducting research and making use of its results to design a prototype or service for testing.

3) Here there is also nees to prepare and implement a schedule

4) Identifying the targets within the project

5) Distributing the tasks and resources to the team

6) Adjusting the members of the project team as needed

6 0
4 years ago
To create a cover letter to send to potential employers along with a resume, what software program should you use?
spayn [35]
Sending letters is easier when an individual is using an email. Emails are very easy to access, they can be sent twenty four / seven (24/7) and can also be received 24/7. Examples of email programs are yahoo and google websites.
3 0
3 years ago
What is the maximum number of edges for an undirected graph? A directed graph?
siniylev [52]

Answer:

For undirected graph n(n-1) for directed graph \frac{n(n-1)}{2}

Explanation:

The maximum number of edges for a undirected graph is given by n(n-1), where n is number of vertices

The maximum number of edges in directed graph is given by \frac{n(n-1)}{2}, where n is number of vertices

The maximum number of edges is greater in undirected graph than directed graph

5 0
4 years ago
SHA-1 gives 160-bit secure hash. Let's assume that a successful brute force attack is possible by trying 2^(160/3) combinations.
pochemuha

Answer:

C) double SHA-1 is stronger because it requires about 2^(160/3) X 2^(160/3) maximum combinations because for each broken first stage, there are 2^(160/3) brute force attempts may be needed.

Explanation:

Double SHA will require about 2^(160/3) X 2^(160/3). for each statage we need to check the 2^(160/3) combinations means it will take lot of time.

4 0
3 years ago
Other questions:
  • A ____ paragraph places the first character of a text line near the left border of a placeholder.
    14·1 answer
  • Devices used for viewing images from one computer to another over the internet
    6·1 answer
  • How do media and networks interact
    11·1 answer
  • Write the definition of a function named printstarbucks that receives a non-negative integer n and prints a line consisting of n
    6·1 answer
  • When using a search engine, what is the name of a word or phrase somebody types to find something online?
    12·2 answers
  • Write a Python program stored in a file q1.py to play Rock-Paper-Scissors. In this game, two players count aloud to three, swing
    13·1 answer
  • Create a presentation on “Pets” and customize your presentation in the following ways:
    10·1 answer
  • Which sentence indicates that Jeff is mentioning the visual synopsis in his proposal while planning a media project?
    10·1 answer
  • You are investigating the use of website and URL content filtering to prevent users from visiting certain websites. Which benefi
    5·1 answer
  • Write algorithm and flowchart for the following<br>a.find the sum and average of any four numbers ​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!