Question

In: Computer Science

C++ question: When cleaning a file the existing data is often read by character. Once a...

C++ question: When cleaning a file the existing data is often read by character. Once a file has been cleaned it is rarely read in by character. Explain Why?

Solutions

Expert Solution

When cleaning a file, special characters need to be removed.

To remove such characters, it is needed to go through all the characters which individually dont have any meaning.

Below are two sentences. It can be observed that some of letters are not usual alphabets, they are a bit different from normal english alphabets. They occur individually as characters. It is needed to access each of them and put a replacement normal character there. like "ē" can be replaced by "e" for the requirement. it may be needed to remove "৷" these symbols and put " "(space there). Characters are stored as 1 byte or more bytes encoding. These 1 byte or more bytes represent different symbols as per encoding. That's why character access is important for cleaning a file.

adhiyajñaḥ kathaṅ kō.tra dēhē.sminmadhusūdana.
prayāṇakālē ca kathaṅ jñēyō.si niyatātmabhiḥ৷৷8.2৷৷

But normally when a file is read, characters individually don't make sense. Even if the file contains numbers, 34 is different than individual 3 and 4. reading character can be used for other purposes but generally words or sentences are required to be read from a file.


Related Solutions

language c++(Data structure) You have to read a file and store a data in character array...
language c++(Data structure) You have to read a file and store a data in character array ( you cant initialize a character array, you have to code generically) code must be generic u must read a file onece u cant use built in function etc string, code in classes if u initialized a char array or ur code doesn't run i will dislike and report u you can use link list to store data
Done in c++, Read an unsorted keywords file once to determine how many words are in...
Done in c++, Read an unsorted keywords file once to determine how many words are in the file. Allocate memory dynamically to store the unsorted keywords in an array of strings or an array of c-strings. (Hint: be sure to clear your input file stream before re-reading the file) Reread the keywords file a second time and store the words in the dynamically allocated array of strings or c-strings Sort the array of key words. (Hint: be sure to check...
Read an unsorted keywords file once to determine how many words are in the file. Allocate...
Read an unsorted keywords file once to determine how many words are in the file. Allocate memory dynamically to store the unsorted keywords in an array of strings or an array of c-strings. (Hint: be sure to clear your input file stream before re-reading the file) Reread the keywords file a second time and store the words in the dynamically allocated array of strings or c-strings Sort the array of key words. (Hint: be sure to check your sorted array...
Read an unsorted keywords file once to determine how many words are in the file. Allocate...
Read an unsorted keywords file once to determine how many words are in the file. Allocate memory dynamically to store the unsorted keywords in an array of strings or an array of c-strings. (Hint: be sure to clear your input file stream before re-reading the file) Reread the keywords file a second time and store the words in the dynamically allocated array of strings or c-strings Sort the array of key words. (Hint: be sure to check your sorted array...
Write a C++ program to read a data file containing the velocity of cars crossing an...
Write a C++ program to read a data file containing the velocity of cars crossing an intersection. Then determine the average velocity and the standard deviation of this data set. Use the concept of vector array to store the data and perform the calculations. Include a function called “Standard” to perform the standard deviation calculations and then return the value to the main function for printing. Data to use. 10,15,20,25,30,35,40,45,50,55. Please use something basic.
Write a C program that will read different data types from the following file and store...
Write a C program that will read different data types from the following file and store it in the array of structures. Given file: (This file have more than 1000 lines of similar data): time latitude longitude depth mag magType nst gap dmin 2020-10-19T23:28:33.400Z 61.342 -147.3997 12.3 1.6 ml 12 84 0.00021 2020-10-19T23:26:49.460Z 38.838501 -122.82684 1.54 0.57 md 11 81 0.006757 2020-10-19T23:17:28.720Z 35.0501667 -117.6545 0.29 1.51 ml 17 77 0.1205 2020-10-19T22:47:44.770Z 38.187 -117.7385 10.8 1.5 ml 15 100.22 0.049 2020-10-19T22:42:26.224Z...
HW_6c - Append data to existing data in a file. Include the following in the main.cpp...
HW_6c - Append data to existing data in a file. Include the following in the main.cpp file. Prompt the user to enter 3 more numbers, then read the numbers and write them to             the results.txt file. Include code so that when the data is written to file, it is appended (added on to the     end of the existing data). Open the results.txt file and verify that the file was written successfully. /* OUTPUT Here are the numbers...
Using OOP, write a C++ program that will read in a file of names. The file...
Using OOP, write a C++ program that will read in a file of names. The file is called Names.txt and should be located in the current directory of your program. Read in and store the names into an array of 30 names. Sort the array using the selection sort or the bubblesort code found in your textbook. List the roster of students in ascending alphabetical order. Projects using global variables or not using a class and object will result in...
Write a C program that will read a character string and then encrypt the string based...
Write a C program that will read a character string and then encrypt the string based on one of the 3 different encryption methods. The type of encryption is to be selected by the user. Encryption method 1: Swapping by position. Characters in the array are swapped with the opposite characters based on their position in the string. Example: Input string – apple. Encrypted string – elppa Method: The first character ‘a’ and the last character ‘e’ – swap their...
The code in this question shows three ways that one can read data from a file...
The code in this question shows three ways that one can read data from a file in a Python program. Answer the following questions: Using the code as an example, explain why Python is a fixed format programming language. Describe what would be output for each of the print statements in the code listing. Given the difference in output, explain the different roles of readLine(), readLines(), and read() functions. with open("rainfall.txt","r") as inFile:    aLine = inFile.readLine() with open("rainfall.txt", "r") as...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT