Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void concatenateStrings(char str1[], char str2[]) {
- int i, j;
- for (i = 0; str1[i] != '\0'; i++);
- for (j = 0; str2[j] != '\0'; i++, j++) {
- str1[i] = str2[j];
- }
- str1[i] = '\0';
- }
- int main() {
- char str1[100], str2[50];
- printf("Enter the first string: ");
- fgets(str1, sizeof(str1), stdin);
- printf("Enter the second string: ");
- fgets(str2, sizeof(str2), stdin);
- concatenateStrings(str1, str2);
- printf("Concatenated string: %s\n", str1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment