Wednesday, January 18, 2006

Lab 1/18 getchar( )&putchar( )

參考程式
====================
#include
void main()
{
char ch;

printf("Input a character:");
ch=getchar();
printf("The charcter you input is ");
putchar(ch);

}
====================

課堂練習1:
配合講義
利用4.getche()與putch()
重寫此程式

練習各種不同的輸入與輸出格式

課堂練習2:
配合講義,利用"C"的檔案(非C++(.cpp))
練習getch()函數

5 Comments:

At Wed Jan 18, 07:34:00 PM, Anonymous Anonymous said...

#include stdio.h
#include conio.h
void main()
{
char ch;

printf("Input a character:");
ch=getche();
printf("The charcter you input is ");
putch(ch);

}

 
At Wed Jan 18, 07:46:00 PM, Anonymous Anonymous said...

#include < stdio.h >
#include < conio.h >
int main()
{
char ch;
printf("Input a character:");
ch=getche();
printf("\nThe charcter you input is ");
putch(ch);
printf("\n");

return 0;
}
還是有換行比較好看^^

 
At Wed Jan 18, 07:47:00 PM, Anonymous Anonymous said...

#include stdio.h
#include conio.h
void main()
{
char ch;

printf("Input a character:");
ch=getch();
printf("The charcter you input is ");
//putch(ch);
printf("\n");

}

與上一則語法不同

 
At Wed Jan 18, 08:18:00 PM, Anonymous Anonymous said...

#include stdio.h
#include conio.h
void main()
{
char ch;

printf("Input a character:\n");
ch=getch();
printf("The charcter you input is ");
putch(ch);
printf("\n");
}

 
At Wed Jan 18, 08:25:00 PM, Anonymous Anonymous said...

#include stdio.h
#include conio.h
void main()
{
char ch;

printf("Input a character:");
ch=getche();

printf("\nThe charcter you input is ");
putch(ch);

printf("\n");
}

 

Post a Comment

<< Home