Question: 1) Write a complete program following these instructions: main.c: contains main function that calls each function in myfunctions.c. myfunctions.h: header file to hold the prototypes
1) Write a complete program following these instructions:
main.c: contains main function that calls each function in myfunctions.c.
myfunctions.h: header file to hold the prototypes of myfunctions.c.
myfunctions.c: void tokenizer(char str[]) that tokenizes str using function strtok and outputs the tokens in reverse order. int totalOcc(char str[],char ch) that returns the total occurance of ch in str using strchr function. char *sortedStrings(char *str[]) that returns a pointer to a sorted array of strings. You may use one of the sorting methods discussed in Ch.6 plus string comparison functions discussed in class. Submit the code with the Compile , run commands and some examples included as a comment.
//============================================================ 2) Trace and write the output of the following code. If the statement contains an error, describe the error and how to correct it.
1. char s1[50]=jack, s2[50]=jill,s3[50],*sptr; 2. printf(%c%s, toupper(s1[0]),&s1[1]) 3. printf(%s,strcpy(s3,s2)); 4. printf(%s),strcat(strcpy(s3,s1), and ),s2); 5. printf(%u, strlen(s1) + strlen(s2)); 6. printf(%u, strlen(s3)); 7. char s[10]; 8. strncpy(s, hello, 5); 9. printf(%s , s); 10.printf(%s, a); 11.char s[12]; 12.strcpy(s,Welcome string2); 13.if ( strcmp (string1, string2)) 14. printf(The strings are equal );
//=================================
Enter three strings from the user, where each string should have a maximum length of 15 characters. Send the three strings to function sort to sort them in ascending order. Print the three strings after sorting. Your function heading should look like the following: void sort(char *s1, char *s2, char *s3)
Example run: Enter three strings: this is easy The strings after sorting: easy is this
(IN C programming language )
please help
thanks:)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
