我正试图在Palindrome
的程序下面运行,但它正在给我Exception error
,请帮忙吗?我正在使用Visual studio 2013
。
#include<iostream>
int main(){
char a[100], b[100];
std::cout << "This is a program to check palindrome or not." << std::endl;
std::cout << "Enter your string:\n" << std::endl;
gets(a);
/*Here string does copy..*/
strcpy(a, b);
/*Here string does reverse..*/
strrev(b);
/*Here string does compare*/
if (strcmp(a, b) == 0){
std::cout << "Congrats, It's palindrome!" << std::endl;
}
else{
std::cout << "Sorry BOSS but this is not a palindrome." << std::endl;
}
return 0;
}
帮助将不胜感激!
答案 0 :(得分:2)
char *strcpy(char *dest, const char *src);
目的地是第一个参数,源是第二个参数。将复制命令更改为
strcpy(b, a);