Since you mentioned that you are a student and want to learn C, I am not going to write a code but will try to point you into the right direction.
To solve this, you need:
- Get a alphanumeric string
- Check if it's a palindrome (you have several options there)
First of all, to get a string, you have in your code:
char a;
scanf("%c", &a);
A hint: this is only getting you one character. To get a string, you first need to allocate an array instead of one single char, and then use scanf with a different argument, not %c.
This part of the task is completely independent of the second part. I recommend first to make sure that this part works before proceeding further. You can do it by getting a string and then immediately printing it. This way you can see what you are actually dealing with.
Once you have your string, proceed with analyzing it. You could revert it and then compare to original (that's what your code is suggesting), but it's probably easier to do something like this:
- Find string length
- Compare each symbol in the string with its symmetrical counterpart. For example, if string length is 10, you'll need to compare symbol #0 with symbol #9, symbol #1 with symbol #8 etc. etc. Hint: you'll need to use a loop here.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…