How to print an entered string backwards in C using only a for loop

前端 未结 6 1078
日久生厌
日久生厌 2021-01-16 12:15

I want to print a string backwards. But my code seems to count down the alphabet from the last letter in the array to the first letter in the array instead of counting down

6条回答
  •  無奈伤痛
    2021-01-16 12:59

    You want to print word[x] (the xth character in the array) instead of x (the xth character in the character set).

    You also want to be counting down indexes, not characters.

    for(x=end, x >= 0; x--)
        printf("%c", word[x]);
    

提交回复
热议问题