当前位置:首页 » 编程语言 » c语言进度条线程
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

c语言进度条线程

发布时间: 2023-01-31 23:41:06

c语言进度条

程序1:#include "stdio.h"
#include <dos.h>
#include <conio.h>
/*去光标函数*/
void no_text_cursor(void)
{
union REGS r;
r.h.ah=1;
r.h.ch=32;
int86(0x10,&r,&r);
}
main()
{
int i;
int bfb;
char b=219;
char c='%';
for(i=1;i<=60;i++)
{ gotoxy(i,1); /*为了能在进度条和百分比之间变动*/
no_text_cursor();
delay(45000);/*前后两个delay是为了让滚动更好看,流畅*/
printf("%c",b);
delay(45000);
gotoxy(31,2); /*为了能在进度条和百分比之间变动*/
bfb=((i*10)/6);
printf("%d",bfb);
gotoxy(34,2);
printf("%");
}
printf("\nLoading Successful!");
getch();
}程序2:#include<graphics.h>
main()
{
int gdriver=DETECT,gmod,i;
/*registerbgidriver(EGAVGA_driver);*/
initgraph(&gdriver,&gmod,"");
setlinestyle(0,0,2);
rectangle(3,215,637,250);
setcolor(RED);
sleep(3);
for(i=0;i<632;++i)
{
if(i==631)break;
line(5+i,216,5+i,249);
delay(2888);
}
getch();
closegraph();
} 以上程序均在TC2.0下通过

㈡ C语言做一个百分比进度条

1.c和js通信 可以用xml来解决,这个就不详细讲了 2.进度条,使用css百分比做,比如: html code <div id="warp" style="width:100px;height:10px;border:1px solid #eee;background:#000;overflow:hidden"><!-#warp用以包裹进度以及显示这个进度条-><div id="point" style="width:[color=#ff0000]90%[/color];background:#44a;height:10px;"></div><!-#point利用百分比控制实现和进度条一直的效果,后面需要的是利用js做width的值的赋值操作如果你的c中不断有当前进度进行输出,那可以在页面中不断调用js函数读取该输出变量,然后调整进度条,

㈢ C语言如何创建线程(windows)系统中

下面为C语言调用WIN API实现创建线程:
1,导入<windows.h>头文件
2,声明实现方法DWORD WINAPI ThreadProc1( LPVOID lpParam ) {}
3,在main()方法中调用 CreateThread(NULL,0 ,ThreadProc1,NULL,0,NULL);
要注意的是主线程不能结束,如果主线程结束,则它的子线程也会被杀死。
#include <windows.h>
#include <stdio.h>
#include<time.h>
DWORD WINAPI ThreadProc1( LPVOID lpParam )
{
int i=0;
time_t timer;
while(1)
{
timer=time(NULL);
printf("The current time is: %s\n",asctime(localtime(&timer)));
sleep(1);
}
}
void main()
{
int i=0;
//让主线程进入循环,主线程若退出,子线程1,2会被系统“杀死”
//创建线程1
CreateThread(
NULL, // default security attributes
0, // use default stack size
ThreadProc1, // thread function
NULL, // argument to thread function
0, // use default creation flags
NULL); // returns the thread identifier
for(;;)
{
;
}
}

㈣ c语言怎么创建线程和使用

进程的生命周期:
[1].创建 --- fork
[2].执行 --- a. exec
b.子进程实现代码逻辑
[3].结束 --- exit _exit
僵尸态进程---wait waitpid
孤儿进程
--------------------------------------
进程存在的问题:
(1).进程的创建 --- 复制
(时间 和 空间的开销很大)
(2).进程的运行 --- 调度-->