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

Question 1: Sorting a text file Craie a thai nris the lu ia file. he futi hou ak

ID: 3607650 • Letter: Q

Question

Question 1: Sorting a text file Craie a thai nris the lu ia file. he futi hou ak tw is: 1. filename to use as input, which should be opened and read line-by-line 2. filename to use as output, which should be populated (by your function) with the same lines as the input, only sorted To test your function, I will call your function like this: sortFile('input.txt', 'output.txt') % should create output.tzt For my input.txt file, I could use the NATO phonetic alphabet, with one line per word, in a random order. For example, the first few lines of my file could be "zulu", "foxtrot", "delta", etc. Your script should create the file output.txt with the contents "alpha", "bravo", "charlie", etc. Submit your function as sortFile.m

Explanation / Answer

#include #include #include #define MAX_LINE 4096 unsigned long int lineCountFile(const char *filename) { FILE *fp = fopen(filename, "r"); unsigned long int linecount = 0; int c; if(fp == NULL){ fclose(fp); return 0; } while((c=fgetc(fp)) != EOF ) { if(c == ' ') linecount++; } fclose(fp); return linecount; } void sortfile(char **array, int linecount) { int i, j; char t[MAX_LINE]; for(i=1;i
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