Modified x_strcmp to take const char*

This commit is contained in:
xavi 2024-09-14 19:44:42 -07:00
parent 2f679ebfa3
commit 787bf40377
2 changed files with 4 additions and 4 deletions

View File

@ -32,9 +32,9 @@ void x_strcpy(char* dest, char* src, const int size_dest){
// compare two strings // compare two strings
// return 0 if equal to eachother // return 0 if equal to eachother
// return -1 if not // return -1 if not
int x_strcmp (char* str1, char* str2){ int x_strcmp (const char* str1, const char* str2){
char* ptr1 = str1; const char* ptr1 = str1;
char* ptr2 = str2; const char* ptr2 = str2;
while(*ptr1 != '\0' && *ptr2 != '\0'){ while(*ptr1 != '\0' && *ptr2 != '\0'){
if(*ptr1 != *ptr2){ if(*ptr1 != *ptr2){

View File

@ -3,7 +3,7 @@
int x_strlen(char*); int x_strlen(char*);
void x_strcpy(char*, char*, const int); void x_strcpy(char*, char*, const int);
int x_strcmp(char*, char*); int x_strcmp(const char*, const char*);
char* x_strconcat(char*, char*); char* x_strconcat(char*, char*);
#endif #endif