Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(str): add strncat implementation #643

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions submodules/LIB/software/modules/iob_str/software/src/iob_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,21 @@ int iob_strlen(char *str) {
}
return c;
}

// concatenate src to dst up to max_len chars
// return concatenated string
char* iob_strncat(char *dst, char *src, int max_len) {
int i = 0;
int j = 0;

while((dst[i] != '\0')){
i++;
}

while((src[j] != '\0') && (j < max_len)){
dst[i++] = src[j++];
}
dst[i] = '\0';

return dst;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
int iob_strcpy(char *dst, char *src);
int iob_strcmp(char *str1, char *str2, int str_size);
int iob_strlen(char *str);
char* iob_strncat(char *dst, char *src, int max_len);