while中的continue用法,getchar及putchar使用方法
生活随笔
收集整理的這篇文章主要介紹了
while中的continue用法,getchar及putchar使用方法
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
//int main()
//{
// int a = 0;
// while (a <= 9)
// {
// a++;
// if (a == 5)
// continue;//在while循環(huán)中,continue負(fù)責(zé)跳過(guò)本次循環(huán)continue后面的代碼
// printf("%d\n", a);
// }
// return 0;
//}
//int main()
//{
// int a = getchar();我認(rèn)為getchar相當(dāng)于讀取輸入字符的ASCII值
// printf("%c\n", a);這個(gè)c將ASCII值轉(zhuǎn)換為字符
// putchar(a); putchar將ASCII值轉(zhuǎn)換為字符并打印
// return 0;
//}
int main() //int main()
{ //{int ch = 0; //int ch=getchar();此時(shí)ch只能是輸入字符的ASCII值while ((ch=getchar()) != EOF) //while(ch!=EOF) 這個(gè)while循環(huán)會(huì)無(wú)限循環(huán)putchar(ch); // putchar(ch);return 0; //return 0;
} //}//
1
#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> int main() {char password[20];printf("請(qǐng)輸入密碼:");scanf("%s", password);int a;while (a = getchar() != '\n')//清理\n之前的數(shù)據(jù){;}printf("是否確認(rèn)密碼Y/N:");int b = getchar();if (b = 'Y')printf("確認(rèn)密碼");elseprintf("否認(rèn)密碼");return 0; }?
總結(jié)
以上是生活随笔為你收集整理的while中的continue用法,getchar及putchar使用方法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Tomcat发布项目时,浏览器地址栏图标
- 下一篇: 弹性云服务器的优势有哪些