Computers and Technology, 19.03.2021 18:00 val452
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: 1
Computers and Technology, 21.06.2019 16:00
What does josh silverman name as the most important aspect of managing finances?
Answers: 2
Computers and Technology, 21.06.2019 23:10
Write a method that accepts a string object as an argument and returns the number of words it contains. for instance, if the argument is "four score and seven years ago", the method should return the number 6. demonstrate the method in a program that asks the user to input a string and then passes that string into the method, printing out whatever the method returns.
Answers: 3
Computers and Technology, 23.06.2019 00:30
Quick pl which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 1
See the lseek_example. c file. Modify the lseek_example. c, such that it reads from an input file (n...
Social Studies, 27.05.2021 21:00
Mathematics, 27.05.2021 21:00
Computers and Technology, 27.05.2021 21:00
Physics, 27.05.2021 21:00
Biology, 27.05.2021 21:00
Arts, 27.05.2021 21:00
English, 27.05.2021 21:00
English, 27.05.2021 21:00
Mathematics, 27.05.2021 21:00
Mathematics, 27.05.2021 21:00
History, 27.05.2021 21:00
Mathematics, 27.05.2021 21:00
Mathematics, 27.05.2021 21:00