Program received signal SIGSEGV, Segmentation fault.是什么地方发生问题了?
小弟刚开始学习c语言,顺着cs50的课程一点一点的学习,现在有个程序出现了问题。我用gdb检查了之后发现报错
Program received signal SIGSEGV, Segmentation fault.
0x76d7b332 in vswprintf () from C:\WINDOWS\SysWoW64\msvcrt.dll
。麻烦大家给看看。谢谢,程序如下:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
int
main (int argc, char *argv[])
{
char y = 'a';
int j = 0;
int i = 0;
char x[10];
while((int)y != 121)
{
printf("\ninput the decode key word in big letter:");
scanf("%s",&x);
printf("\nthe key word is %s , if it is right input y, if you want to input another key work print any other key: ", x);
fflush(stdin);
scanf("%c",&y);
for(int a = 0;a < strlen(x); a++)
{
if ((int)x[a] < 65 || (int)x[a] > 90)
{
printf("please input the correct word!");
y = 'a';
break;
}
}
}
char z[150];
int n[50];
int c = 0;
int b = 0;
int d = 1;
int f = 0;
int g = 0;
while(d != 0) 从这里开始出现问题了
{
printf("\ninput the sentence you want to transcode: ");
fflush(stdin);
gets(z);
if(strlen(z)%3 == 0)
{
while(b < strlen(z))
{
n[c] = ((int)z[b]-48)*100 + ((int)z[b+1]-48)*10 + ((int)z[b+2]-48);
c++;
b = b + 3;
printf("%c",z[b]);
}
d = 0;
}
else
printf("\nplease in put the correct password.");
}
/*printf("well done and %d and %d",n[1],n[9]);*/
while(i < strlen(z)/3)
{
if ( j == strlen(x) )
{
j = j - strlen(x);
}
z[i] =(char) (n[i] - (int) x[j] + 91);
printf("%s",z[i]);
i++;
j++;
}
int q = 0;
while(q != 13)
{
printf("\npress enter to quit the program");
fflush(stdin);
q = getch();
}
}
程序的主要思想是用户输入我之前一个小程序得到的密码,每3个数能转化成一个字母