intmain() { int i; char c; printf("\nQuick Format 1.44MB\n"); printf("Program by ChenQingyang.\n"); printf("ALL DATA IN THE FLOPPY DISK WILL BE LOST!!\n"); printf("\nInsert a diskette for drive A:\n"); printf("and press ENTER when ready. . ."); c=getchar(); printf("\n\nCleaning FAT area. . ."); buff[0]=0xf0; buff[1]=buff[2]=0xff; for (i=3;i<512;i++) buff[i]=0; abswrite(0,1,1,buff); abswrite(0,1,10,buff); for (i=0;i<512;i++) buff[i]=0; for (i=2;i<10;i++) abswrite (0,1,i,buff); for (i=11;i<19;i++) abswrite (0,1,i,buff); printf("\nCleaning ROOT area. . ."); for (i=19;i<33;i++) abswrite (0,1,i,buff); printf("\n\nQuickFormat Completed!\n"); }
上述代码是一个使用 DOS 命令格式化软盘的程序。它会提示用户输入软盘,然后清空软盘的FAT和根目录区域,并在完成后打印 “QuickFormat Completed!” 的信息。程序使用了 <dos.h> 和 <stdio.h> 头文件,其中包含了一些 DOS 和标准输入输出函数。
intmain(void) { unsignedint size, segp; int stat; size = 64; /* (64 x 16) = 1024 bytes */ stat = allocmem(size, &segp); if (stat == -1) printf("Allocated memory at segment: %x\n", segp); else printf("Failed: maximum number of paragraphs available is %u\n",stat); return0; }
intmain(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode;
int midx, midy; int stangle = 45, endangle = 135; int radius = 100;
/* initialize graphics and local variables */ char ch[] = ""; initgraph(&gdriver, &gmode, ch);
/* read result of initialization */ errorcode = graphresult(); /* an error occurred */ if (errorcode != grOk) { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit(1); /* terminate with an error code */ }
t.tm_sec = 1; /* Seconds */ t.tm_min = 30; /* Minutes */ t.tm_hour = 9; /* Hour */ t.tm_mday = 22; /* Day of the Month */ t.tm_mon = 11; /* Month */ t.tm_year = 56; /* Year - does not include century */ t.tm_wday = 4; /* Day of the week */ t.tm_yday = 0; /* Does not show in asctime */ t.tm_isdst = 0; /* Is Daylight SavTime; does not show in asctime */
/* converts structure to null terminated string */
strcpy(str, asctime(&t)); printf("%s\n", str);
return0; }
9.3 运行结果
10. asin
10.1 函数说明
函数声明
函数功能
double asin(double x);
反正弦函数
10.2 演示示例
1 2 3 4 5 6 7 8 9 10 11 12
#include<stdio.h> #include<math.h>
intmain(void) { double result; double x = 0.5;
result = asin(x); printf("The arc sin of %lf is %lf\n", x, result); return(0); }