我正在尝试创建一个程序,该程序检查给定的数组/字符串是否是回文,并且不起作用。该程序仅在每个给定的数组上打印“ 0”,即使在回文上也是如此。
int main()
{
char string[100]= {0};
char stringReverse[100]= {0};
int temp = 0;
int firstLetter = 0;
int lastLetter = 0;
printf("Please enter a word or a sentence: ");
fgets(string, 100, stdin);
strcpy(stringReverse , string); // This function copies the scanned array to a new array called "stringReverse"
firstLetter = 0;
lastLetter = strlen(string) - 1; //because in array, the last cell is NULL
// This while reverses the array and insert it to a new array called …Run Code Online (Sandbox Code Playgroud)