C言語プログラムの例

1260 ワード

C言語百例の読み書き文字列
文字列の大文字と小文字の変換
#include
#include
int main(int argc, char const *argv[])
{
    char ar;
    printf("please input some char 
"); do { // ar=getchar(); if(islower(ar))// ar=toupper(ar);// else ar=tolower(ar); putchar(ar); }while(ar!='q'); return 0; }

-この例では、主に文字の大文字と小文字の変換であり、toupper()とtolower()を使用します.関数ctypeに含める.hの中.
-getchar()関数を使用する場合は、getchar()の元の形式で入力がバッファリングされ、車に戻って必要な場所に書き込まれることに注意する必要があります.これが行バッファ入力です.だからhにはgetche()とgetch()の2つの関数が提供されています.–
char br =getche();//        ;
getch()//     ;

単純な開閉関数
#include
#include
int main(int argc, char const *argv[])
{
    FILE*fp;
    char ch,filename[10];
    printf("Please input the name of the file :
" ); scanf("%s",filename); if ((fp=fopen(filename,"r")==NULL)) { printf("can't open the file
"); exit(0); } fclose(fp); return 0; }

-この例では、ファイルの開く関数と閉じる関数fopen()について簡単に説明します.
転載先:https://www.cnblogs.com/VCctor/p/5100706.html