一个简单的程序,使用while循环,getchar()和putchar()进行小写到大写的转换 [英] a simple programme on lowercase to uppercase conversion using while loop, getchar() and putchar()

查看:577
本文介绍了一个简单的程序,使用while循环,getchar()和putchar()进行小写到大写的转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用while循环,getchar()和putchar()进行小写到大写的转换程序???



发布者:OP:

  #include    <   stdio.h  >  
#include < conio .h >
#include < ctype.h > ;

#define EOL'\ n'
main()
{
char 字母[ 80 ];
int 标记,count = 0 ;
letter [count] = getchar();
while (letter [count]!= EOL)
{

count = count + 1;
letter [count] = getchar();

}
tag = count;
count = 0 ;
while (count)
}

解决方案

我得到了这个解决方案,实际上我无法理解第一个循环的逻辑????你会在xplain xplain me ???

  #define'\ n'
main()
{
char 字母[ 80 ];
int 标记,count = 0 ;
letter [count] = getchar();
while (letter [count]!= EOL)
{
count = count + 1;
letter [count] = getchar();
}
tag = count;
count = 0 ;
while (count





我不知道从哪里得到它 - 很明显你没有写它 - 但循环非常简单。

它依次查看字符串中的每个字母,直到它出现行尾字符(定义为换行符)。第一次进入时,它会查看用户是否以换行符开始。每次循环时,它会将用户的一个字符插入到字符串中。然后将其查看为看看它刚刚插入的角色是否为行尾字符。



如果你不确定是什么,请用铅笔在纸上画出来:将数组制作成一系列的方框,并手动计算每条指令的作用,并将其复制到纸上 - 用这么简单的东西,你可以更容易地看到正在发生的事情,而不是用调试器。


how can i do a programme on lowercase to uppercase conversion using while loop, getchar() and putchar() ???

Posted by OP:

#include <stdio.h>
#include <conio.h>
#include <ctype.h>

#define EOL '\n'
main()
{
    char letter[80];
    int tag , count=0;
    letter[count]=getchar();
    while(letter[count]!= EOL)
    {
    
        count=count+1;
        letter[count]=getchar();
        
    }
    tag=count;
    count=0;
    while(count)
}

解决方案

"i got this solution bt actually i can''t understand the logic of the first loop???? will u plzz xplain me???"

#define EOL '\n'
main()
   {
   char letter[80];
   int tag , count=0;
   letter[count]=getchar();
   while(letter[count]!= EOL)
      {
      count=count+1;
      letter[count]=getchar();
      }
   tag=count;
   count=0;
   while(count



I don''t know where you got it from - it''s clear you didn''t write it - but the loop is pretty simple.
It looks at each letter in the string in turn, until it comes to an end of line character (defined as a newline). First time in, it looks to see if the user started with a newline. Each time round the loop, it inserts a character from the user into the string. It then looks at it to see if the character it just inserted was the end of line character.

If you aren''t sure what something does, draw it out on paper with a pencil: make an array a series of boxes, and manually work out what each instruction does, and copy it on the paper - with something this simple it is probably easier for you to see what is going on that way, than to look at memory with the debugger.


这篇关于一个简单的程序,使用while循环,getchar()和putchar()进行小写到大写的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆