Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Language: my program below is working but there is something wrong. When I run it I have to type something in first before it

C Language:

image text in transcribed

my program below is working but there is something wrong. When I run it I have to type something in first before it will pop up and I have to do it each time. I tried everything and nothing work. Also, the names did not list in alphabetical order. You will see what I mean when you run the program. I need the program fix within one hour. Thanks!

//#include //#include //#include #define SIZE 15 /* string length limit, including \0 */ #define LIM 30 /* maximum number of lines to be read */ #define HALT "" /* null string to stop input */

void stsrt2(char *strings[], int num);/* string-sort function */ char * s_gets(char * st, int n); void upperCase(char *);

void roll(void) { int total = 0; /* input count */ int k; /* output count */ char first[LIM][SIZE]; char last[LIM][SIZE]; char *ptstr1[LIM]; char *ptstr2[LIM]; getchar(); printf("Input up to %d student name, and I will sort them. ",LIM); printf("To stop, press the Enter key at a line's start. "); //while (total

printf("Enter First Name: "); s_gets(first[total],SIZE); ptstr1[total] = first[total]; upperCase(first[total]);

printf("Enter Last Name: "); s_gets(last[total],SIZE); ptstr2[total] = last[total]; upperCase(last[total]); total++; } stsrt2(ptstr1, total); stsrt2(ptstr2, total);

printf(" Here are the names: "); for (k = 0; k

/* string-pointer-sorting function */ void stsrt2(char *strings[], int num) { char *temp; int top, seek; for (top = 0; top 0) { temp = strings[top]; strings[top] = strings[seek]; strings[seek] = temp; } }

char * s_gets(char * st, int n) { char * ret_val; int i = 0; ret_val = fgets(st, n, stdin); if (ret_val) { while (st[i] != ' ' && st[i] != '\0') i++; if (st[i] == ' ') st[i] = '\0'; else // must have words[i] == '\0' while (getchar() != ' ') continue; } return ret_val; }

void upperCase(char * str) { while (*str) { *str = toupper(*str); str++; } }

Create a program that prints a class roll sheet in alphabetical order. The user inputs the students' first name and last names (separately!), and presses enter on the first name when done. The program prints out the roster like this... HATFIELD, HEIDI KAISER, RUSSELL LIPSHUTZ, HOWARD PENKERT, DAWN WRIGHT, ELIZABETH

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Inductive Databases And Constraint Based Data Mining

Authors: Saso Dzeroski ,Bart Goethals ,Pance Panov

2010th Edition

1489982175, 978-1489982179

More Books

Students also viewed these Databases questions

Question

3. Job rotation is used for all levels and types of employees.

Answered: 1 week ago