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]
2 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]2 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 is the privacy risks with health care robots?
Ann [662]
Health care robots the key word, being "robots" aren't able to act as we can as humans.

Robots and systems lack the emotional skills that we as humans have, they are not intuitive.

There are many risks in using robots for health care, although, "health care" is a vague term, so I'll cover a few in general:
- Doctor/patient confidentiality is risked when using robots to handle personal medical matters, systems are never 100% secure.

- Robots and systems cannot emphasise with patients and will make decisions based on logic and theoretics, not emotionally - for example, if a patient is in a state of bad mental health, a robot will not be able to effectively analyse the right methods to take.

- The collection, storage and passing-on of patient information is risked as system encryption is never guaranteed.
3 0
3 years ago
Use the drop-down menus to complete the statements about creating a table of contents in Word 2016.
siniylev [52]

Answer:

1.headings and subheadings

2.manually

3.options

6 0
2 years ago
Ano ang word processor at electronic spreadsheet​
AveGali [126]

Answer:

excel

Explanation:

3 0
2 years ago
Read 2 more answers
CODING TIME
Fynjy0 [20]

Answer:

food_list = ['rice', 'beans','yam', 'bread', 'pasta', 'cocoa','tea']

one_more = ['meat']

extend_list = food_list + one_more

print(extend_list)

Output : ['rice', 'beans','yam', 'bread', 'pasta', 'cocoa','tea', 'meat']

food_list.append('milk')

print(food_list)

Output : ['rice', 'beans','yam', 'bread', 'pasta', 'cocoa','tea', 'milk']

food_list.insert(0, 'cake')

print(food_list)

Output : ['cake', 'rice', 'beans','yam', 'bread', 'pasta', 'cocoa','tea']

flowers = ['rose', 'hibiscus', 'lily']

flowers.remove('rose')

print(flowers)

Output : ['hibiscus', 'lily']

To remove rose using pop()

flowers.pop(0)

Explanation:

The + operator and append method adds elements to the end of an existing list item.

The insert method adds element at the specified index

Remove method deletes element by stating the name of the element to be deleted while pop deletes element using the index value of the element.

7 0
2 years ago
In computer science, what does it mean to interface?
Sati [7]

D, To communicate with a computer through a device or program :)

3 0
2 years ago
Other questions:
  • Amitha writes up a one-page summary of a novel during her summer internship at a publishing company. When she reads over the pag
    10·1 answer
  • What's the main piece of information you look for in an e-mail message you're investigating??
    14·2 answers
  • Which of the following would you not see on a windows 10 start menu?
    6·1 answer
  • While speech recognition can operate without any confi guration, you can train it to more accurately recognize your voice. true
    5·1 answer
  • , 13 dB correspond to a power ratio of ....?
    14·1 answer
  • ppose we have a Rectangle class that includes length and width attributes, of type int, both set by the constructor. Define an e
    9·1 answer
  • Assuming outFile is a file stream object and number is a variable, which statement writes the contents of number to the file ass
    13·1 answer
  • Heres a meme<br><br>free pints as well, because why not.​
    10·2 answers
  • What are some common uses of Excel?
    10·1 answer
  • JAVA CODE.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!