我想从这个代码从控制台输入,但它给我运行时异常在某些内存位置,每次我尝试运行它并输入第一个可能的输入。 我正在使用Visual Studio 2010.我遇到了与MingW和Dev C++相同的问题。但是,旧的TurboC3编译器的代码运行良好。运行时异常与输入使用scanf或获取在C
int Nowhere(int x);
...
char* AtBashEncrypt(char* message);
char* AtBashDecrypt(char* encrypted);
int main()
{
char *input = "", *ciphertext = "", *plaintext = "";
system("cls");
printf("AtBash Cipher\nEnter a string to be encrypted: ");
gets(input); //this is where I get the error
ciphertext = AtBashEncrypt(input);
...
getch();
}
它可能有什么问题吗?
你还没有分配的内存。 – 2013-03-08 03:56:40