In the situation where there are multiple users or a networked computer system, you probably share a printer with other users. When you request to print a file, your request is added to the print buffer. When your request reaches the front of the print buffer, your file is printed. This ensures that only one person at a time has access to the printer and that this access is given on a first-come, first-served basis. Write a C program to implement the above scenario.
#include <stdio.h>
int main() {
char *c;
printf("Enter file path:");
scanf("%s", &c);
FILE *file = fopen(c, "r");
if (file) {
size_t len = 0;
char *arr;
while (getline(&arr, &len, file) != -1) {
printf("%s", arr);
}
}
return 0;
}
Comments
Leave a comment