So, I have the code below where I need to concatenate the first 'N' characters from str2 into str1. But IDK why when I type the str1 he automatically jumps to reading N and skips the str2 reading, str1 and str2 reading is exatcly the same.
#include <stdio.h>
#include <string.h>
int main(void) {
char str1[50], str2[25];
int n, tam;
printf("Type the first string: ");
scanf("%[^\n]s", str1);
printf("Type the second string: ");
scanf("%[^\n]s", str2);
printf("Type N: ");
scanf("%d", &n);
tam = strlen(str1);
for(int i=0; i<n; i++){
tam++;
str1[tam] = str2[i];
}
printf("Final string: %s\n", str1);
return 0;
}