- 25日 函数返回数组
- 26日 system("cls")
- 28日 gotoxy(x, y)
函数返回数组
// 功能:返回一个长度为3,int类型,值为{1, 2, 3}的数组
int *fun() {
int *a;
a=(int *)malloc(sizeof(int)*3);
a[0]=1;//数组定义时没有初始化,不能整体赋值 ,要单个赋值。
a[1]=2;
a[2]=3;
return a;
}
// 功能:返回一个长度为3,int类型,值为{1, 2, 3}的数组
int *fun() {
static int a[] = {1, 2, 3};
return a;
}
26日 system(“cls”)
system(“cls”)
system函数代表执行系统命令,system("cls")就是执行命令”清屏“的意思。
程序
#include#include int main() { printf("你好"); system("cls"); printf("世界"); return 0; }
运行
世界 -------------------------------- Process exited after 0.453 seconds with return value 0 请按任意键继续. . .28日 gotoxy(x, y)
gotoxy(x, y)
将光标移动到指定位置
程序
# include# include //Sleep()、gotoxy()、HideCursor() void gotoxy(int x, int y) { //gotoxy 源代码 COORD pos; pos.X = x - 1; pos.Y = y - 1; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); } int main() { printf("你好"); gotoxy(10, 10); printf("世界"); return 0; }
运行
你好
世界
--------------------------------
Process exited after 0.4297 seconds with return value 0
请按任意键继续. . .



