Runtime Error
代码
#include <stdio.h>
#include <ctype.h>
#define N 5
#define KEY 4
void
get(char *s)
{
int c;
char *p = s;
while((c=getchar()) !='\n')
{
*p = c;
p++;
}
*p = '\0';
}
int
main(void)
{
char str[N+1];
get(str);
for (int i=0; i < N; i++)
{
if (islower(str[i]))
str[i] = (str[i] + KEY - 'a' ) % 26 + 'a';
else if (isupper(str[i]))
str[i] = (str[i] + KEY - 'A' ) % 26 + 'A';
}
for (char *p=str; *p != '\0'; p++)
printf("%c", *p);
return 0;
}