Hi
I am writing a small library, which I want to contain a method for reversing strings.
I have the following in a header file:
In my main function I have a char string[MAX_STR_LEN] = "something"; and then call reverse_string(string);Code:// This header file contains function for all sorts of string manipulation. // In this first release, the three members of the string lib., is: // * Reverse string // * Parse for certain characters // * Seperate // The function to be created, is Reverse string. // This function will take a string as a parameter, and returns the reversed string. #include <string.h> #include <stdlib.h> #define MAX_STR_LEN 100 SOMETYPE reverse_string(char string[MAX_STR_LEN]) { char revstring[MAX_STR_LEN]; // Reversed string int len; // Length of incoming string int j; // Counter variable len = strlen(string); // Get length of incoming string for(int i = len; i >0; i--) // Reverse the string { revstring[j] = string[i]; j++; } return ???????? }
But ofcourse, the compiler complains about the types....how could I do this?




Reply With Quote