Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a program in C using Xv6 O.S. where: 1. The program reads lines of a file

ID: 3751903 • Letter: C

Question

Create a program in C using Xv6 O.S. where:

1. The program reads lines of a file and then prints out all of the lines of the file MINUS consecutive lines that are duplicates of one another

2. If there is no file, the program reads the input from stdin and does the same

(Xv6 C is a little different to the C we're used to, as there is no stdio, printf calls 2 parameters, etc.

You can view the code in this file that controls for word count to help get a better sense of the format:

#include #include #include "types.h" "stat.h" "user,h" char buf[5121; void wc (int fd, char *name) int i, n; int 1, w, c, inword; inword while((n - ; =read(fd, buf, sizeof (buf))) > 0){ for(i-e; i

Explanation / Answer

Here is working the code for your requirement

Please comment below for further queries with the code or any modifications needed. Thank you.

#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE *fp;
char f_Name[100], ch;
printf("Enter the f_Name to open ");
scanf("%s", f_Name);
   fp = fopen(f_Name, "r");
if (fp == NULL)
{
printf("Cannot open file ");
exit(0);
}
   ch = fgetc(fp);
while (ch != EOF)
{
printf ("%ch", ch);
ch = fgetc(fp);
}
fclose(fp);
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote