博文

函数大全(g开头)(2006-11-27 19:49:00)

摘要:  函数名: gcvt
功 能: 把浮点数转换成字符串
用 法: char *gcvt(double value, int ndigit, char *buf);
程序例: #include
#include int main(void)
{
char str[25];
double num;
int sig = 5; /* significant digits */ /* a regular number */
num = 9.876;
gcvt(num, sig, str);
printf("string = %s\n", str); /* a negative number */
num = -123.4567;
gcvt(num, sig, str);
printf("string = %s\n", str); /* scientific notation */
num = 0.678e5;
gcvt(num, sig, str);
printf("string = %s\n", str); return(0);
}


函数名: geninterrupt
功 能: 产生一个软中断
用 法: void geninterrupt(int intr_num);
程序例: #include
#include /* function prototype */
void writechar(char ch); int main(void)
{
clrscr();
gotoxy(80,25);
writechar('*');
getch();
return 0;
} /*
outputs a character at the current cursor
position using the video BIOS to avoid the
scrolling of the screen when writing to
l......

阅读全文(1344) | 评论:0

函数大全(f开头)(2006-11-27 19:47:00)

摘要:
  double fabs(double x); 返回双精度x的绝对值。
void far *farcalloc(unsigned long nunits,unsigned long unitsz); 堆中给含有nu从远nits个元素的,每个元素占用unitsz个字节长的数组分配存贮区。
成功是返回指向新分配的内存块的指针;若存贮空间不够,返回NULL。   unsigned long farcoreleft(void); 返回远堆中未用存贮区的大小。
void farfree(void far *block); 释放远堆中以前所分配内存块。
void far *farmalloc(unsigned long nbytes); 从远堆分配长nbytes字节的内存块,返回新地址。
void far *farrealloc(void far *oldblock,unsigned long nbytes); 调整已分配的内存块的大小为nbytes。需要的话,可把块中的内容复制到新位置。要注意:所有的可用的RAM可被分配,大于64K的块可被分配。
远指针用于存取被分配的块。返回重新分配的内存块的地址。若存贮块重新分配失败,返回NULL。 struct fcb { char fcb_drive; /* 0 = default, 1 = A, 2 = B */ char fcb_name[8]; /* File name */ char fcb_ext[3]; /* File extension */ short fcb_curblk; /* Current block number */ short fcb_recsize; /* Logical record size in bytes */ long fcb_filsize; /* File size in bytes */ short fcb_date; /* Date file was last written */ char fcb_resv[10]; /* Reserved for DOS */ char fcb_currec; /* Current record in bl......

阅读全文(1849) | 评论:0

函数大全(e开头)(2006-11-27 19:46:00)

摘要:
  函数名: ecvt
功 能: 把一个浮点数转换为字符串
用 法: char ecvt(double value, int ndigit, int *decpt, int *sign);
程序例: #include
#include
#include int main(void)
{
char *string;
double value;
int dec, sign;
int ndig = 10; clrscr();
value = 9.876;
string = ecvt(value, ndig, &dec, &sign);
printf("string = %s dec = %d \
sign = %d\n", string, dec, sign); value = -123.45;
ndig= 15;
string = ecvt(value,ndig,&dec,&sign);
printf("string = %s dec = %d sign = %d\n",
string, dec, sign);
value = 0.6789e5; /* scientific
notation */
ndig = 5;
string = ecvt(value,ndig,&dec,&sign);
printf("string = %s dec = %d\
sign = %d\n", string, dec, sign); return 0;
}

函数名: ellipse
功 能: 画一椭圆
用 法: void far ellipse(int x, int y, int stangle, int endangle,
int xradius, int yradius);
程序例: #include
#include
#include
#include int main(void)
{
......

阅读全文(1115) | 评论:0

函数大全(d开头)(2006-11-27 19:44:00)

摘要:
  函数名: delay
功 能: 将程序的执行暂停一段时间(毫秒)
用 法: void delay(unsigned milliseconds);
程序例:
/* Emits a 440-Hz tone for 500 milliseconds */
#include int main(void)
{
sound(440);
delay(500);
nosound(); return 0;
}

函数名: delline
功 能: 在文本窗口中删去一行
用 法: void delline(void);
程序例: #include int main(void)
{
clrscr();
cprintf("The function DELLINE deletes \
the line containing the\r\n");
cprintf("cursor and moves all lines \
below it one line up.\r\n");
cprintf("DELLINE operates within the \
currently active text\r\n");
cprintf("window. Press any key to \
continue . . .");
gotoxy(1,2); /* Move the cursor to the
second line and first column */
getch(); delline();
getch(); return 0;
}
函数名: detectgraph
功 能: 通过检测硬件确定图形驱动程序和模式
用 法: void far detectgraph(int far *graphdriver, int far *graphmode);
程序例: #include
#include
#include
#include /......

阅读全文(1285) | 评论:0

函数大全(c开头)(2006-11-27 19:40:00)

摘要:
  函数名: cabs
功 能: 计算复数的绝对值
用 法: double cabs(struct complex z);
程序例: #include
#include int main(void)
{
struct complex z;
double val; z.x = 2.0;
z.y = 1.0;
val = cabs(z); printf("The absolute value of %.2lfi %.2lfj is %.2lf", z.x, z.y, val);
return 0;
}


函数名: calloc
功 能: 分配主存储器
用 法: void *calloc(size_t nelem, size_t elsize);
程序例: #include
#include int main(void)
{
char *str = NULL; /* allocate memory for string */
str = calloc(10, sizeof(char)); /* copy "Hello" into string */
strcpy(str, "Hello"); /* display string */
printf("String is %s\n", str); /* free memory */
free(str); return 0;
}


函数名: ceil
功 能: 向上舍入
用 法: double ceil(double x);
程序例: #include
#include int main(void)
{
double number = 123.54;
double down, up; down = floor(number);
up = ceil(number); printf("original number %5.2lf\n", number); <......

阅读全文(861) | 评论:0

函数大全(b开头)(2006-11-27 19:38:00)

摘要: 函数名: bar
功 能: 画一个二维条形图
用 法: void far bar(int left, int top, int right, int bottom);
程序例: #include
#include
#include
#include int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy, i; /* initialize graphics and local variables */
initgraph(&gdriver, &gmode, ""); /* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
} midx = getmaxx() / 2;
midy = getmaxy() / 2; /* loop through the fill patterns */
for (i=SOLID_FILL; i......

阅读全文(1499) | 评论:0

函数大全(a开头)(2006-11-27 19:36:00)

摘要:
  函数名: abort
功 能: 异常终止一个进程
用 法: void abort(void);
程序例:
#include
#include int main(void)
{
printf("Calling abort()\n");
abort();
return 0; /* This is never reached */
}

函数名: abs
功 能: 求整数的绝对值
用 法: int abs(int i);
程序例:
#include
#include int main(void)
{
int number = -1234; printf("number: %d absolute value: %d\n", number, abs(number));
return 0;
}

函数名: absread, abswirte
功 能: 绝对磁盘扇区读、写数据
用 法: int absread(int drive, int nsects, int sectno, void *buffer);
int abswrite(int drive, int nsects, in tsectno, void *buffer);
程序例:
/* absread example */ #include
#include
#include
#include int main(void)
{
int i, strt, ch_out, sector;
char buf[512]; printf("Insert a diskette into drive A and press any key\n");
getch();
sector = 0;
if (absread(0, 1, sector, &buf) != 0)
{
perror("Disk problem");
exit(1);
}

阅读全文(1072) | 评论:0

Turbo C(V2.0)编译错误信息(2006-11-27 19:34:00)

摘要: 
  编译错误信息

  说明:Turbo C 的源程序错误分为三种类型:致命错误、一般错误和警告。其中,致命错误通常是内部编译出错;一般错误指程序的语法错误、磁盘或内存存取错误或命令行错误等;警告则只是指出一些得怀疑的情况,它并不防止编译的进行。

  下面按字母顺序A~Z分别列出致命错误及一般错误信息,英汉对照及处理方法:

(一)、致命错误英汉对照及处理方法:

A-B致命错误

Bad call of in-line function (内部函数非法调用)
分析与处理:在使用一个宏定义的内部函数时,没能正确调用。一个内部函数以两个下划线(__)开始和结束。

Irreducable expression tree (不可约表达式树)
分析与处理:这种错误指的是文件行中的表达式太复杂,使得代码生成程序无法为它生成代码。这种表达式必须避免使用。

Register allocation failure (存储器分配失败)
分析与处理:这种错误指的是文件行中的表达式太复杂,代码生成程序无法为它生成代码。此时应简化这种繁杂的表达式或干脆避免使用它。

(二)、一般错误信息英汉照及处理方法

#operator not followed by maco argument name(#运算符后没跟宏变元名)
分析与处理:在宏定义中,#用于标识一宏变串。“#”号后必须跟一个宏变元名。

'xxxxxx' not anargument ('xxxxxx'不是函数参数)
分析与处理:在源程序中将该标识符定义为一个函数参数,但此标识符没有在函数中出现。

Ambiguous symbol 'xxxxxx' (二义性符号'xxxxxx')
分析与处理:两个或多个结构的某一域名相同,但具有的偏移、类型不同。在变量或表达式中引用该域而未带结构名时,会产生二义性,此时需修改某个域名或在引用时加上结构名。

Argument # missing name (参数#名丢失)
分析与处理:参数名已脱离用于定义函数的函数原型。如果函数以原型定义,该函数必须包含所有的参数名。......

阅读全文(826) | 评论:0

附录二:Turbo C(V2.0)使用指南(2006-11-27 19:33:00)

摘要:
 
(本文的许多命令或方法同样适用于TC3)   在开始看本文以前,我先说明一下C语言的安装和使用中最应该注意的地方:许多网友在下载Turbo C 2.0和Turbo C++ 3.0后,向我问得最多的是在使用过程中碰到如下问题:

1)出现找不到 stdio.h conio.h等include文件;

2)出现cos.obj无法连接之类的错误
  这些问题是由于没有设置好路径引起的,目前下载的TC2,TC3按安装分类大概有两种版本:一是通过install安装,这类应该已经设置好了路径;二是直接解压后建立TC.EXE的快捷方式,在WINDOWS下双击即可运行(DOS下直接运行TC.EXE),目前国内大多为这种,因此下载使用前请注意
路径设置:
设置方法为:
OPTION->DIRECTORIES:
INCLUDE: [TC2/3所在目录]/include
LIB: [TC2/3所在目录]/lib
output输出目录请自己设置一个工作目录,以免混在一起。最后还提醒一点:FILES中的Change dir(改变当前目录)中应设置为当前程序所在目录。

一、 Turbo C 2.0的安装和启动

  Turbo C 2.0的安装非常简单, 只要将1#盘插入A驱动器中, 在DOS的"A>" 下键入: A>INSTALL 即可, 此时屏幕上显示三种选择:
1. 在硬盘上创造一个新目录来安装整个Turbo C 2.0系统。

2. 对Turbo C 1.5更新版本。这样的安装将保留原来对选择项、颜色和编辑功能键的设置。

3. 为只有两个软盘而无硬盘的系统安装Turbo C 2.0。

  这里假定按第一种选择进行安装, 只要在安装过程中按对盘号的提示, 顺序插入各个软盘, 就可以顺利地进行安装, 安装完毕将在C盘根目录下建立一个TC 子目录, TC下还建立了两个了目录LIB和INCLUDE, LIB子目录中存放库文件, INCLUDE子目录中存放所有头文件。运行Turbo C2.0时, 只要在TC 子目录下键入TC并回车即可进入Turbo C 2. 0 集成开发环境。

阅读全文(941) | 评论:0

附录一:Turbo C(V2.0)编译错误信息(2006-11-27 19:32:00)

摘要:
  编译错误信息

  说明:Turbo C 的源程序错误分为三种类型:致命错误、一般错误和警告。其中,致命错误通常是内部编译出错;一般错误指程序的语法错误、磁盘或内存存取错误或命令行错误等;警告则只是指出一些得怀疑的情况,它并不防止编译的进行。

  下面按字母顺序A~Z分别列出致命错误及一般错误信息,英汉对照及处理方法: (一)、致命错误英汉对照及处理方法: A-B致命错误 Bad call of in-line function (内部函数非法调用)
分析与处理:在使用一个宏定义的内部函数时,没能正确调用。一个内部函数以两个下划线(__)开始和结束。 Irreducable expression tree (不可约表达式树)
分析与处理:这种错误指的是文件行中的表达式太复杂,使得代码生成程序无法为它生成代码。这种表达式必须避免使用。 Register allocation failure (存储器分配失败)
分析与处理:这种错误指的是文件行中的表达式太复杂,代码生成程序无法为它生成代码。此时应简化这种繁杂的表达式或干脆避免使用它。 (二)、一般错误信息英汉照及处理方法 #operator not followed by maco argument name(#运算符后没跟宏变元名)
分析与处理:在宏定义中,#用于标识一宏变串。“#”号后必须跟一个宏变元名。

'xxxxxx' not anargument ('xxxxxx'不是函数参数)
分析与处理:在源程序中将该标识符定义为一个函数参数,但此标识符没有在函数中出现。 Ambiguous symbol 'xxxxxx' (二义性符号'xxxxxx')
分析与处理:两个或多个结构的某一域名相同,但具有的偏移、类型不同。在变量或表达式中引用该域而未带结构名时,会产生二义性,此时需修改某个域名或在引用时加上结构名。 Argument # missing name (参数#名丢失)
分析与处理:参数名已脱离用于定义函数的函数原型。如果函数以原型定义,该函数必须包含所有的参数名。 Argument list syntax error (参数表出现语法错误)
分析与处理:函数调用的参数间必须以......

阅读全文(769) | 评论:0