c语言的群

远志999 2004-01-07 03:13:27
谁有学习c语言的qq群啊,让我加一下!
谢谢!
...全文
59 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
birdnofoot 2004-01-08
  • 打赏
  • 举报
回复
楼上的gotoxy()是一个什么函数啊?贴一下吧
arfi 2004-01-08
  • 打赏
  • 举报
回复
gotoxy是TC系列的编译器提供的函数,表示光标移动到x列,y行处。

如下程序在VC上编译通过:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>

#define KEY_ESC 0x1b
#define KEY_UP 0x48
#define KEY_DOWN 0x50

#define MAX_MENU_LEN 12 /*最长的菜单项所占字符数目*/


void main(void)
{
char menu[][MAX_MENU_LEN] = {"\r==> menu1\n", "\r menu2\n", "\r menu3\n"};
char indicator[] = "==>";
int num, i, oldselect, newselect; /*num用来记录选择菜单的数目,oldselect用来标记原来选中的菜单,newselect用来标记新选中的菜单*/
int key; /*记录按键*/

system("cls");
oldselect = newselect = 1;
num = sizeof(menu)/sizeof(*menu);
for(i=0; i<num; i++)
printf("%s", menu[i]);

while(1)
{
key = getch();
if(key == KEY_ESC)
break;
else
{
key = getch();
if(key == KEY_UP)
{
if(oldselect == 1)
newselect = num;
else
newselect--;
}
else if(key == KEY_DOWN)
{
if(oldselect == 3)
newselect = 1;
else
newselect++;
}
for(i=0; i<strlen(indicator); i++)
{
menu[oldselect-1][i+1] = ' ';
menu[newselect-1][i+1] = indicator[i];
}
oldselect = newselect;
system("cls");
for(i=0; i<num; i++)
printf("%s", menu[i]);
}
}
}

arfi 2004-01-07
  • 打赏
  • 举报
回复
#include <stdio.h>
#include <conio.h>
#include <bios.h>

#define KEY_ESC 0x011b
#define KEY_UP 0x4800
#define KEY_DOWN 0x5000

void main(void)
{
char *menu[] = {"\r menu1\n", "\r menu2\n", "\r menu3\n"};
int num, i, select; /*num用来记录选择菜单的数目,select用来标记当前选中的菜单*/
int y; /*记录显示菜单的初始行*/
int key; /*记录按键*/

clrscr();
y = wherey();
num = sizeof(menu)/sizeof(*menu);
for(i=0; i<num; i++)
printf("%s", menu[i]);
gotoxy(y, 1);
printf("==>");

select = 1;
while(1)
{
key = bioskey(1); /*检测是否有键按下*/
if(key) /*如果有*/
{
key = bioskey(0); /*取得按下的键值*/
if(key == KEY_ESC)
break;
if(key == KEY_UP)
{
printf("\r "); /*清除当前的 ==>*/
if(select == 1) /*如果到了菜单顶,仍然按下了UP键*/
{
select = num;
gotoxy(1, y+num-1);
printf("==>");
}
else /*其它时候按下了UP键*/
{
select--;
gotoxy(1, y+select-1);
printf("==>");
}
}
else if(key == KEY_DOWN)
{
printf("\r ");
if(select == num)
{
select = 1;
gotoxy(1, y);
printf("==>");
}
else
{
select++;
gotoxy(1, y+select-1);
printf("==>");
}
}
}
}
}
mainSean 2004-01-07
  • 打赏
  • 举报
回复
不知道!

69,373

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧