Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <string.h>
- char* strcpyy(char* s2, const char* s1);
- int strlenn(const char* s);
- char* strcatt(char* s1, const char* s2);
- int main() {
- char str1[30] = "Hello, ";
- char str2[] = "World!";
- printf("count of str1 = %d\n", strlenn(str1));
- strcatt(str1, str2);
- printf("Concatenated string: %s\n", str1); // Output: "Hello, World!"
- return 0;
- }
- char* strcpyy(char* s2, const char* s1)
- {
- while (*s1)
- {
- *s2 = *s1;
- s1++;
- s2++;
- }
- *s2 = '\0';
- return s2;
- }
- char* strcatt(char* s1, const char* s2)
- {
- int first_end = strlenn(s1);
- while (*s2)
- {
- *(s1 + first_end) = *s2;
- first_end++;
- s2++;
- }
- *(s1 + first_end) = '\0';
- return s1;
- }
- int strlenn(const char* s)
- {
- int count = 0;
- while (*s)
- {
- s++;
- count++;
- }
- return count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement