您的位置:首页 > 其它

编写一个程序读入一行输入,然后反向打印该行,您可以把输入存储在一个char数组中: 假定该行不超过255个字符。回忆一下,您可以使用具有%c说明符的scanf()从输入中一次 读入一个字符,而且当您按

2012-04-29 22:55 2675 查看
#include "stdafx.h"
#include "stdlib.h"

void main()
{
int a=0,i=0;
char word[255];

printf("Please input a word: ");
scanf("%c",&a);

while(a<255 && a!='\n')
{
word[i++]=a;
scanf("%c",&a);
}

i--;
while(i>=0)
printf("%c",word[i--]);
printf("\n");

system("pause");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  存储 c include system input
相关文章推荐