I'm working on a program that's supposed to generate a 40 character random string of uppercase letters A-Z, then generate a random replacement string of random uppercase letters A-Z of length between 2 and 20. It displays the 40 character string, but when I enter the length of the replacement string, it says that Lab4B.exe stopped working and the program terminates. Anyone know what the problem could be?
#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
int main (void)
{
char s1[40];
char s2[20];
char c=' ';
int index;
int a=0;
for(index=0; index<40; index++)
{
s1[index]=rand()%26+'A';
}
s1[40]='\0';
printf ("%s", s1);
printf("\n Enter length of replacement string:");
scanf("%d",a);
for(index=0; index<a; index++)
{
s2[index]=rand()%26+'A';
}
return 0;
}