I am trying to input 2 strings in C, and output a 3rd string which the concatenation of string 1 and 2.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
*
*/
int main(int argc, char** argv) {
char stringarray1 [30];
char stringarray2 [30];
char stringarray3 [30];
int length;
printf("Please enter some text less than 30 characters long\n");
scanf("%[a-z, ]", &stringarray1);
printf("Please enter some text less than 30 characters long\n");
scanf("%[a-z, ]", &stringarray2);
strcat(stringarray1, stringarray2);
//length = strlen(stringarray);
printf("The combined string is %s\n", stringarray1);
return (EXIT_SUCCESS);
}
It allows me to input the first string, but then prints the seond and third printf statement, without allowing me to enter the second string.
How can i enter the second string without it exiting? Why does it exit?