NEW HERE? USE "AFORUM20" TO GET GET 20 % OFF CLAIM OFFER

UK: +44 748 007-0908 USA: +1 917 810-5386
My Orders
Register
Order Now

Convert C to Mips

      Convert into Mips #include <stdio.h> #include <string.h> /** * @brief Function finds locations to chars matching the token in given string, stores in an array of pointers */ void delim(char* str, char token); /** * @brief Function sorts words from given string into alphabetical order */ void sort(char* str, char* loc[], int loc_len); void main() { char str[40]; char* ptr = str; fgets(ptr, 40, stdin); delim(ptr, ' '); printf("n%sn", ptr); return; } void delim(char* str, char token) { char* loc[40] = { NULL }; int j = 0; int length = strlen(str); loc[j] = str; j++; for (int i = 1; i < length; i++) { if (*(str + i) == token) { loc[j] = str + i + 1; *(str + i) = ' '; j++; } } sort(str, loc, j); return; } void sort(char* str, char** loc, int loc_len) { char buffer[40] = { "n" }; printf("String -1: %sn", str); for (int i = 0; i < loc_len; i++) { printf("String %d:", i);// For debug, remove later printf("%sn", loc[i]); // For debug, remove later } strcpy(str, buffer); return; }