⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 4-4.c

📁 《C语言程序设计实训》源代码
💻 C
字号:
/*4-4.c*/
#include<stdio.h>
#include<stdlib.h>
#include<graphics.h>
#include<conio.h>
#include<dos.h>
void getstr(int x,int y,char *str){
int key;
char ch;
char s[2];
int i=0;
s[1]='\0';
setfillstyle(SOLID_FILL,WHITE);
setcolor(LIGHTGRAY);
outtextxy(x+i*8,y,"_");
while((
key=getch())!=13){
if((key==8)||(key==75)){
if(i>0){
i--;
bar(x+i*8,y,x+(i+2)*8-1,y+8);
outtextxy(x+i*8,y,"_");
 }
}else if(ch=(char)(key&0x00ff)){
str[i]=ch;
s[0]=ch;
bar(x+i*8,y,x+(i+1)*8-1,y+9);
setcolor(LIGHTGRAY);
outtextxy(x+i*8,y,s);
outtextxy(x+(i+1)*8,y,"_");
i++;
}
else{
sound(1000);
delay(100);
nosound();
}
}
str[i]='\0';
setcolor(WHITE);
outtextxy(x+i*8,y,"_");
}
main()
{
int gd=DETECT,gm;
 char *str1;
initgraph(&gd,&gm," ");
 setbkcolor(WHITE);
 getstr(100,100,str1);
 getch();
 closegraph();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -