首页 > 其他分享 >getchar

getchar

时间:2022-11-16 22:00:52浏览次数:45  
标签:tmp ch int printf password getchar

//getchar
#include<stdio.h>
int main()
{
	//
	char password[20] = { 0 };
	printf("请输入密码:>");
	scanf_s("%s", password);
	printf("请确认密码(Y/N):>" );
	//清理缓冲区
	//getchar();//处理'\n'
	//清理缓冲区的多个字符
	int tmp = 0;
	while (tmp = getchar()!='\n')
	{
		;
	}
	int ch = getchar();
	if (ch == 'Y')
	{
		printf("确认成功\n");
	}
	else
	{
		printf("确认失败\n");
	}
	return 0;
}

标签:tmp,ch,int,printf,password,getchar
From: https://www.cnblogs.com/xiaofu2022/p/16897660.html

相关文章

  • C语言getchar和putchar是怎么实现的?
    所有的stdio库函数,比如包括getchar/putchar/getc/putc之类的,都会经过stdiobuffer:如果从最简单的实现来说,可以把FILE结构体定义成下面这样:typedefstruct_iobuf{......
  • scanf() getchar()输入问题
    #define_CRT_SECURE_NO_WARNINGS1#include<stdio.h>intmain(){intret=0;intch=0;charmima[20]={0};printf("请输入密码:");scanf("%s",mima);prin......
  • C语言中的getchar、putchar函数
    getchar可以接受键盘上打印的字符,puchar可以进行输出字符比如:#include<stdio.h>intmain(){intch=getchar();putchar(ch);printf("%c\n",ch);return0;}运......
  • switch,putchar,getchar
    今天主要自学了switch,putchar,getchar语句加深了一下理解#include<stdio.h>intmain(){ intch; while((ch=getchar())!=EOF)//getchar接受字符 { putchar(ch);......
  • putchar与getchar
    putchar基本功能:字符输出,输出时只能一个一个来例如:先后输入BOY三个字符#include<stdio.h>intmain(){chara='B',b='O',c='Y';putchar(a);putchar(b);putchar(c);......
  • Unity使用Font.GetCharacterInfo 和 Font.RequestCharactersInTexture获取UnityEngine
    usingUnityEngine;usingUnityEngine.UI;publicclassFontTest:MonoBehaviour{voidStart(){Test();}voidTest(){str......