伊蒂之屋是什么品牌:一道c语言的题
来源:百度文库 编辑:查人人中国名人网 时间:2024/10/05 22:05:01
write a C program that accepts a string of characters from a terminal and displays the string one word per line.
尽快,谢谢!
空格怎么表示阿?
回车是\n,空格是什么?
尽快,谢谢!
空格怎么表示阿?
回车是\n,空格是什么?
#include <stdio.h>
#include <conio.h>
#define N 100
int main()
{
char a, ch[N] = {'\0'};
int i, n = 0;
printf("enter a string: \n");
a = getche();
do
{
if (a == 9 || a == 13 || a == 32)
{
a = '\n';
}
ch[n++] = a;
}while ((a = getche()) != 27);
printf("\n%s", ch);
return 0;
}
按ESC键结束输入
逐字循环,发现空格就输出回车,最后遇到结束符终止
刚才有人说我得程序有错,所以改完整了,
注; 忽略字符串中的空格,当作字符串结束
#include<stdio.h>
void main()
{
printf("请输入要测试的字符串!\n");
char buffer[256];
scanf("%s",buffer);
int i=0;
while(buffer[i] !='\0')
{
printf("%c\n",buffer[i]);
i++;
}
}
兄弟,你的C程序有错啊,不能用SCANF来写,用GETS()来输入,不然你是输不进去的.大体意思都差不多.遇到这种问题差不多都用数组来做.但输入的时候是要一次性输进去,不能有回车的.
楼主问的空格啊.我忘记了.自己去查ASC||代码就知道了。