In C given an text file such as this "input.txt "
122345543221
3215123
12341234
287823883288432
888898888
099878
099990
723847238949238
63276276
9812983932487
3456712332176543
83274828374
sort each line in digits 0-9 and remove repeating digits
for example 576839201 would be 0123456789
#include <stdio.h>
#include <stdlib.h>
void initializeArr(int arr[])
{
int i=0;
for(i=0;i<10;i++)
arr[i]=-1;
}
int main(void) {
int i=0,arr[10];
initializeArr(arr);
FILE *fp = fopen("input.txt", "r");
if(fp == NULL) {
perror("Unable to open file!");
exit(1);
}
char chunk[128];
int val;
while(fgets(chunk, sizeof(chunk), fp) != NULL) {
int length=strlen(chunk);
for(i=0;i<length;i++)
{
if(chunk[i]!='\n')
{
val=chunk[i]-48;
arr[val]=val;
}
}
for(i=0;i<10;i++)
{
if(arr[i]!=-1)
printf("%d",arr[i]);
}
printf("\n");
initializeArr(arr);
}
fclose(fp);
}
Output:

In C given an text file such as this "input.txt " 122345543221 3215123 12341234 287823883288432 888898888...
Write a C Program that: - Creates an input file (input.txt) - Take user inputted integer for number of lines in the input file - accepts inputted text from command line to the input file (input.txt) - saves and closes file. (input.txt) - reopens and displays the newly inputted contents of the file
Write a C++ program that reverses a file. More specifically, given an input file (input.txt) your program will reverse every line in the input. This program does not have an output file, as it modifies the input file directly. You may assume that your input file has 1000 lines or less, if this helps. sample input: Hello World! I study C++ following output: !dlroW olleH ++C yduts I
C++ CODE NEEDED WITH (//) COMMENTS You are given a file called input.txt with the following data input.txt 45 92 34 52 34 Write code that will copy the contents of the file into an array. You can assume that the file will only have 5 data values
In C, we use FILE *inFile = fopen(“input.txt”, “r”) to open a file to read from. From the following choices, choose all of the correct ways of doing it in C++. a. ifstream inFile(“input.txt”); b. ifstream inFile; inFile(“input.txt”); c. ifstream inFile; inFile.open(“input.txt”); d. ifstream inFile = open(“input.txt”); b a c d In C, we would use fclose(inFile) to close the previously opened input file. From the following choices, choose all of the correct ways of doing...
Write a program that opens a text file called input.txt and reads its contents into a stack of characters. The program should then pop the characters from the stack and save them in a second text file called output.txt. The order of the characters saved in the second file should be the reverse of their order in the first file. We don’t know the text file length. Input.txt This is a file is for test output.txt tset rof si elif...
Using C++, and <iostream> if possible,
Write a program that can compress a text file consisting of English language alphabet A-zl using run-length encoding scheme. (Weight 50%) Run-Length Encoding The key idea is to replace the repeating character by itself and the number of times that it has been repeated. Consider the following string HELLO WORLD This can be re-written as HEL20 WORLD Notice that since LL was repeated, it was repeated by L2. 2 here indicates that letter...
I am creating a program to sort a list of names from a given text file using linked listed. The text file would look something like this: 3 John Johnson 1 Tim Boring 1 Jason Mendoza 1 Bobert Reed 2 Tim Boring 4 5 Essentially I would like to associate each numerical value with an action: 1 = add a person, 2 = remove person, 3 = check if that name is in the list, 4 = print list, 5...
construct a cross-reference index for a given text file. Such index structures have applications in the design of compilers and databases. Our task is to write a program that while reading a text file collects all words of the text and retains the numbers of the lines in which each word occurred. When this scan is terminated, a table is printed showing all collected words in alphabetical order with lists of line numbers where they occurred. There would be only...
c# csci312: character counter - vector design a program that reads in an ascii text file (provided) ... Your question has been answered Let us know if you got a helpful answer. Rate this answer Question: C# CSCI312: Character Counter - Vector Design a program that reads in an ASCII text file (provide... C# CSCI312: Character Counter - Vector Design a program that reads in an ASCII text file (provided) and creates an output file that contains each unique ASCII...