This is a language question.

Asked 2 years ago, Updated 2 years ago, 49 views

// Enter code here

#include <stdio.h>

int main()
{
    char rivers[100];
    int count;

    scanf("%s",rivers);

    while(rivers[count] != 0)   
    {
        count++;
    }


    for(;count>=0;count--)
        printf("%s",rivers[count]);

    return 0;
}

When I receive a string and try to print it out in reverse order leaving the position of null, but if I run it, the error window appears with null output, so what's wrong?

array

2022-09-22 18:24

1 Answers

Once the count is not initialized, it is %c instead of %s when outputting to . It's an array of characters.


2022-09-22 18:24

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.