(Sorry,My explaining is bad) 1. Create a test file named bio.txt ////////////bio
ID: 3660118 • Letter: #
Question
(Sorry,My explaining is bad) 1. Create a test file named bio.txt ////////////bio.txt////////////// jones 84 michaels 16 fredrickson 22 (I already have this bio.txt created on my cpu) mitchell 7 franklin 45 johnson 77 //////////////////////////////////////////// 2. The file will have the following format: 3. Read this file and create two arrays 4. One array should contain the last name of all seniors (age >= 65) 5. the other array should contain the last name of all children (age < 18) 6. print out both arrays ******EXAMPLE*****:DISPLAY jones 84 michaels 16 fredrickson 22 mitchell 7 franklin 45 johnson 77 ******the result would be:**** SENIORS jones johnson CHILDREN michaels mitchellExplanation / Answer
#include /* required for file operations */ #include /* for clrscr */ #include /* for delay */ FILE *fr; /* declare the file pointer */ main() { int n; long elapsed_seconds; char line[80]; clrscr(); fr = fopen ("elapsed.dta", "rt"); /* open the file for reading */ /* elapsed.dta is the name of the file */ /* "rt" means open the file for reading text */ while(fgets(line, 80, fr) != NULL) { /* get a line, up to 80 chars from fr. done if NULL */ sscanf (line, "%ld", &elapsed_seconds); /* convert the string to a long int */ printf ("%ld ", elapsed_seconds); } fclose(fr); /* close the file prior to exiting the routine */ } /*of main*/Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.