【发布时间】:2014-04-02 13:39:15
【问题描述】:
我正在制作一个程序,将特定数字添加到字符串中每个字符的 ASCII 值。该代码在运行时给了我一个“分段错误(核心转储)”错误。我究竟做错了什么?我是 C 新手。
#include<stdio.h>
main()
{
int a,b,c;
char x[1000],y[1000];
printf("String:");
gets(x);
printf("\nShift:");
scanf("%d",a);
b=0;
printf("\n");
while (b < strlen(x))
{
c=x[b] + a;
printf("%c",c);
b++;
}
}
【问题讨论】:
-
scanf("%d",a);让它 scanf("%d",&a);
标签: c encryption shift