读取一个字符

#include <stdio.h>
#include <string.h>

int main(){
    int i;
    char msg[25];

    printf(Type up to 25 characters and then press Enter...\n);
    for (i = 0; i < 25; i++)
    {
        msg[i] = getchar(); //read a single character
        if (msg[i] == '\n')
        {
            i--;
            break;
        }
    }

    putchar('\n'); // One line break after the loop is done.
    for (; i >= 0; i--)
    {
        putchar(msg[i]);
    }
    putchar('\n');

    return(0);
}

相关文章

for遍历数组
。。。
声明一个计数循环
咕咕咕
#include <stdio.h> int main (void) { printf (&quo...