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
emmasim [6.3K]
3 years ago
5

Write a program in main.c that reads the file lorum.txt and counts the number of characters on each line. Your program should cr

eate a file named count.txt. The contents of count.txt will contain the character count you computed for each line in lorum.txt. For each line in lorum.txt, your count.txt file must contain a line in the following format: linenumber: number_of_characters The character count for a line should not include the "newline character" (\n).
Computers and Technology
1 answer:
Aneli [31]3 years ago
4 0

Answer:

A C programming language was used to write a file lorum.txt and counts the number of characters on each line.

Explanation:

Raw_Code :

#include<stdio.h>

int main(){

  FILE *read,*write;       //creating file pointers

  int line=1,count=0;

  char ch;

  read = fopen("lorum.txt","r");   //opening files to read and write

  write = fopen("count.txt","w");

  while((ch = getc(read))!=EOF){       //reading lines until end of the file

      if(ch == '\n'){                   //if new line character encountred

          fprintf(write,"%d: %d\n",line,count);       //Then printing count of that line to file  

          line++;                       //incrementing the count of lines

          count = 0;                   //making characters count to 0

      }

      else{

          count++;           //if it is not new line character then increasing character count

      }

  }

  fprintf(write,"%d: %d",line,count);   //writing last lines count to count.txt

  fclose(read);

  fclose(write);

  return 0;

}

You might be interested in
Define Technology. Explain the term.​
aleksandrvk [35]

Answer:

Technology refers to methods, systems, and devices which are the result of scientific knowledge being used for practical purposes. Technology is changing fast. They should be allowed to wait for cheaper technologies to be developed.

7 0
3 years ago
Read 2 more answers
Olivia is an amputee who wears a prosthetic right hand. Which technology would most help her operate a computer?
satela [25.4K]
Nerve interface is technology that allows amputees to use thoughts to move prosthetics
3 0
2 years ago
Question 2 of 3
frozen [14]

Answer: D

Explanation: You don't need to give money, information, or watch any inappropriate content on the gov website. It's safe and all you do is read.

4 0
3 years ago
Read 2 more answers
An organization's contact information includes its _____.
lianna [129]
I would say that it probably includes all of these, but if that's not an option, then it's: email address 
3 0
3 years ago
Read 2 more answers
Question 3 : what tool can diagnose and fix many common linux filesystem problems?
vaieri [72.5K]
The t<span>ool that can diagnose and fix many common linux file system problems is </span>fsck.  fsck, is Linux's file system check utility. It's similar in purpose to the DOS and Windows CHKDSK and ScanDisk utilities. 
3 0
3 years ago
Other questions:
  • You just realized the turn signal on your vehicle is broken,
    15·1 answer
  • What happened to Henry at the end of Chapter 4 in Bendy and the ink machine?
    9·2 answers
  • You use the _____ sheet in the format cells dialog box to position data in a cell by centering it, for example.​
    8·1 answer
  • Blue light reduces quality sleep and comes from
    9·2 answers
  • Write a program thattakes a number x and its exponent y from the user and thencalculate the result
    10·1 answer
  • Software project management is the process planning, organizing, and monitoring of the development of a software project from it
    15·1 answer
  • Select the correct answer.
    7·1 answer
  • Cora is writing a program to make a motorcycle racing game. If Cora wants to speed of the motorcycle to appear on the screen whe
    12·1 answer
  • Write a class definition line and a one line docstring for the class Dog. Write an __init__ method for the class Dog that gives
    11·1 answer
  • HELP ME PLEASE 41 PTS
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!