#include <fstream>
#include <iostream>
using namespace std;
class Line_count
{
string line;
ifstream file_to_read;
public:
int read_file(string fname)
{
int i=-1;
file_to_read.open(fname);
if (!file_to_read.is_open())
{
cout << " File not found " << endl;
return -1;
}
else
{
i=0;
while ( getline (file_to_read,line) )
{
if(line.substr(0,2)!="//" && line.length() !=1) // check
for comment and check for empty string which has length 1
i=i+1;
}
file_to_read.close();
}
return i;
}
};
int main ()
{
char file_name[10][20];
int loc[10];
int i=-1;
Line_count L;
char ans;
do
{
i=i+1;
cout<<" Enter file name :: ";
cin>>file_name[i];
loc[i]=L.read_file(file_name[i]);
cout<<" Wist to continue reading file :: (Y/N) ";
cin>>ans;
}while(ans!='N');
for(int j=0;j<=i;j++)
{
if(loc[j]==-1)
cout<<" "<<file_name[j]<<" not found ";
else
cout<<" "<<file_name[j]<<" LOC is
"<<loc[j];
}
return 0;
};
Output
WRITE A CODE IN C++ A CLASS WITH MEMBER FUCNTIONS THAT COUNTS THE LINES OF CODE...
This is for C++ Write a program that reads in a sequence of characters entered by the user and terminated by a period ('.'). Your program should allow the user to enter multiple lines of input by pressing the enter key at the end of each line. The program should print out a frequency table, sorted in decreasing order by number of occurences, listing each letter that ocurred along with the number of times it occured. All non-alphabetic characters must...
Word count. A common utility on Unix/Linux systems. This program counts the number of lines, words (strings of characters separated by blanks or new lines), and characters in a file (not including blank spaces between words). Write your own version of this program. You will need to create a text file with a number of lines/sentences. The program should accept a filename (of your text file) from the user and then print three numbers: The count of lines/sentences The count...
Please write this in C.
Write this code in Visual Studio and upload your Source.cpp file for checking (1) Write a program to prompt the user for an output file name and 2 input file names. The program should check for errors in opening the files, and print the name of any file which has an error, and exit if an error occurs opening any of the 3 For example, (user input shown in caps in first line) Enter first...
Write a C++ program that reads text from a file and encrypts the file by adding 6 to the ASCII value of each character. See section 5.11 in Starting out with C++ for information on reading and writing to text files. Your program should: 1. Read the provided plain.txt file one line at a time. Because this file has spaces, use getline (see section 3.8). 2. Change each character of the string by adding 6 to it. 3. Write the...
Python Programming Write a program that counts how often a word occurs in a text file. Input: Ask the user for the name of an ASCII text file. Output: Display the numbers of top frequently appeared words and their frequencies. Pseudocode: 1) Read the file 2) Split the file into words 3) Count each word 4) Sort the words by frequencies, starting with the most frequent ones 5) Internally you should use some sort of data structure to keep track...
Please write the following code in C++ for Data
Structures class. Please follow all the instructions in the picture
below. Please write the program with zero warnings.
Description: Please write a short program, randomStream, that asks for the name of a file and a number, and produces a files satisfying the following conditions: The file name is the name given by the user (exactly--no added suffixes please) The number of lines in the file is exactly the same as the...
//I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which manipulates text from an input file using the string library. Your program will accept command line arguments for the input and output file names as well as a list of blacklisted words. There are two major features in this programming: 1. Given an input file with text and a list of words, find and replace every use of these blacklisted words with the string...
Linux & Unix Write a bash program to indent the code in a bash source file. Conditions: The source file will contain only printing characters, spaces, and newlines. It is not necessary to check for invalid input. The source file will not contain comments (words beginning with #). Requirements: Read from standard input, write to standard output. Code inside while statements should be indented 2 spaces. Be sure your program includes all of the following: ...
Write a program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename and input the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line numbers range from 1 to the number of lines in the file. If the input is 0, the program...
For this lab, you can assume that no string entered by the user will be longer than 128 characters. You can also assume that the database file does not contain more than 128 lines. However, you can not assume that the database has the correct format. There are three commands your program must handle. If any other command is entered, the program should reply Unrecognized command. and then present the prompt again. The three commands are: quit - The program...