Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string.h>
- #include <stdlib.h>
- #include <stdio.h>
- int main()
- {
- char *a = "12 34 56";
- int a_l = strlen(a);
- printf("str1: \"%s\" (%d)\n", a, a_l);
- char *b = "___";
- int b_l = strlen(b);
- printf("str2: \"%s\" (%d)\n", b, b_l);
- for (int i = 0; i < a_l; i++) {
- if (a[i] == ' ') {
- char *o = malloc(a_l + b_l);
- strncpy(o, a, i);
- strncpy(o + i, b, a_l);
- //strncpy help
- printf("out: \"%s\"\n", o);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment