Need program written in C, not C+ or anything else. Also needs documentation thr
ID: 3833012 • Letter: N
Question
Need program written in C, not C+ or anything else. Also needs documentation throughout the programa) problem #9 page 513 of the 6th Edition (Modified by RJM) Write a program that processes a list of names in which each name is on a separate line of at most 80 characters. Here are two sample names: Hartman-Montgomery, Jane R. Doe, JD On each line the surname is followed by a comma and a space. Next comes the first name or initial, then a space and the middle initial. Your program should scan the names into three arrays surname, first, and middle init If the surname is longer than 15 characters, store only the first 15. Similarly, limit the first name to 10 characters. Do not store periods in the first and middle init arrays. Write the array's contents to the screen aligning the contents of each column: Hartman-Montgom Jane R Doe OR
Explanation / Answer
Answer:
C Programme:
firstly, reading files line by line
FILE *ifp, *ofp;
char *mode="r";
char outputFilename[]="out.list";
ifp=fopen("in.list",mode);
if(ifp==NULL)
{
fprintf(stderr,"Con't open input file in.list! ");
exit(1);
}
ofp=fopen(outputFilename,"w");
if (ofp == NULL)
{
fprintf(stderr,"Con't open output file %s! ", outputFilename);
exit(1);
}
Suppose the input file consists of lines with username and other data :
in.list
--------
Hartman-Montgom jane R
Doe J D
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.