实用技巧之while里面使用getchar或sleep函数

                                   我们经常需要打印一些变量的取值来调试程序,使用while(1)是常用的手段。

                                  

              while (1)
        {
            char letter = getchar();
            printf("test_point is %d \t\n", test_point);
            printf("test_point is %f \t\n", test_point);
            //printf("右移一些位数%d \t\n", (test_point & 0xff00) >> 16);
            //printf("hello world\n");
            //scanf("%d", &normal_point);
            printf(" letter is %c\n", letter);
        }




                 while (1)
        {
        
            printf("test_point is %d \t\n", test_point);
            printf("test_point is %f \t\n", test_point);
            Sleep(1000);
        }

                     

#include "common.h"
#include <stdio.h>
#include <stdlib.h>
 
static float Mathematical_modeling = 0;
static int   capacitance_modeling  = 0;
static int   value = 0;

int main()
{
    while (1)
    {
        value = getchar();
        switch (value)
        {
           case '1':
               printf("人工智障\n");
               break;
           case '2':
               printf("Vim实用技巧\n");
               break;
           case '3':
               printf("嵌入式linux\n");
           case '4':
               printf("linux gpio\n");
               break;
           case '5':
               printf("linux DMA\n");
               break;
           case '6':
               printf("linux KEY POLL\n");
           case '7':
               printf("Linux I2C \n");
           case '8':
               printf("Linux RTOS\n");
               break;
           case '9':
               printf("Linux Task\n");
               break;
        }
        printf("value is %c\n", value);
    }
    return 0;
} 

 

                                    

 

posted @ 2020-02-25 18:56  卷哭你  阅读(558)  评论(0编辑  收藏  举报