回 帖 发 新 帖 刷新版面

主题:新手系列(5)

函数名: ecvt
功  能: 把一个浮点数转换为字符串
用  法: char ecvt(double value, int ndigit, int *decpt, int *sign);
程序例:
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

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 <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   int midx, midy;
   int stangle = 0, endangle = 360;
   int xradius = 100, yradius = 50;

   /* initialize graphics, 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;
   setcolor(getmaxcolor());

   /* draw ellipse */
   ellipse(midx, midy, stangle, endangle,
    xradius, yradius);

   /* clean up */
   getch();
   closegraph();
   return 0;
}
  
  

函数名: enable
功  能: 开放硬件中断
用  法: void enable(void);
程序例:

/* ** NOTE:
This is an interrupt service routine. You can NOT compile this program
with Test Stack Overflow turned on and get an executable file which will
operate correctly.
*/

#include <stdio.h>
#include <dos.h>
#include <conio.h>

/* The clock tick interrupt */
#define INTR 0X1C

void interrupt ( *oldhandler)(void);

int count=0;

void interrupt handler(void)
{
/*
   disable interrupts during the handling of the interrupt
*/
   disable();
/* increase the global counter */
   count++;
/*
   re enable interrupts at the end of the handler
*/
   enable();
/* call the old routine */
   oldhandler();
}

int main(void)
{
/* save the old interrupt vector */
   oldhandler = getvect(INTR);

/* install the new interrupt handler */
   setvect(INTR, handler);

/* loop until the counter exceeds 20 */
   while (count < 20)
      printf("count is %d\n",count);

/* reset the old interrupt handler */
   setvect(INTR, oldhandler);

   return 0;
}
  
  

函数名: eof
功  能: 检测文件结束
用  法: int eof(int *handle);
程序例:

#include <sys\stat.h>
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <io.h>

int main(void)
{
   int handle;
   char msg[] = "This is a test";
   char ch;

   /* create a file */
   handle = open("DUMMY.FIL",
   O_CREAT | O_RDWR,
   S_IREAD | S_IWRITE);

   /* write some data to the file */
   write(handle, msg, strlen(msg));

   /* seek to the beginning of the file */
   lseek(handle, 0L, SEEK_SET);

   /*
      reads chars from the file until hit EOF
   */
   do
   {
      read(handle, &ch, 1);
      printf("%c", ch);
   } while (!eof(handle));

   close(handle);
   return 0;
}
  
  

函数名: exec...
功  能: 装入并运行其它程序的函数
用  法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL);
int execle(char *pathname, char *arg0, arg1, ..., argn, NULL,
     char *envp[]);
int execlp(char *pathname, char *arg0, arg1, .., NULL);
int execple(char *pathname, char *arg0, arg1, ..., NULL,
      char *envp[]);
int execv(char *pathname, char *argv[]);
int execve(char *pathname, char *argv[], char *envp[]);
int execvp(char *pathname, char *argv[]);
int execvpe(char *pathname, char *argv[], char *envp[]);
程序例:

/* execv example */
#include <process.h>
#include <stdio.h>
#include <errno.h>

void main(int argc, char *argv[])
{
   int i;

   printf("Command line arguments:\n");
   for (i=0; i<argc; i++)
      printf("[%2d] : %s\n", i, argv[i]);

   printf("About to exec child with arg1 arg2 ...\n");
   execv("CHILD.EXE", argv);

   perror("exec error");

   exit(1);
}
  
  

函数名: exit
功  能: 终止程序
用  法: void exit(int status);
程序例:

#include <stdlib.h>
#include <conio.h>
#include <stdio.h>

int main(void)
{
   int status;

   printf("Enter either 1 or 2\n");
   status = getch();
   /* Sets DOS errorlevel  */
   exit(status - '0');

/* Note: this line is never reached */
   return 0;
}
  
  

函数名: exp
功  能: 指数函数
用  法: double exp(double x);
程序例:

#include <stdio.h>
#include <math.h>

int main(void)
{
   double result;
   double x = 4.0;

   result = exp(x);
   printf("'e' raised to the power \
   of %lf (e ^ %lf) = %lf\n",
   x, x, result);

   return 0;
}

回复列表 (共7个回复)

沙发

[size=+1][color=blue]蚩尤:[/color][/size]
谢谢,回家马上测试,不过我还得将一些语句改成试适vc++6.0的,有点麻烦,也正好是个锻炼提高的机会。

板凳

好 :
  新手系列1,2,3没找到 能不能再贴一下
  或发到偶的邮箱 ianislet@hotmail.com谢谢[em2]
  贴在新手系列4里大概没看到现在贴到新手系列5里
  5185time@163.com这个人也要 他也贴在新手系列4里了
  希望这次你能看到 给回音哦

3 楼

你们查一下你们的邮箱,我发给你们了啊!!!

4 楼

没有呀 不是我们 我和他不认识 就是知道他也要 把他也写进来了

5 楼

你的C很好么 平时工作会用么 好象很少有公司用C开发软件
我也不是很了解 只是大学是学计算机的 但是是为了应付考试
才学的 学一门丢一门 现在工作了想重头拾起来 知道技术的
重要性了 我想了解平时的工作中如果用不到C怎么锻炼自己
的水平呢 如果学过很多语言 想提高编程水平是不是把C学好
就很好了 可是总得有人给你布置任务有程序给你编啊 不然
只能把书上的例题做一遍 有人说做例题也很管用 把例子背
出来就行了 积少成多融会贯通 真的么 还有呢 你的很多例子
很管用 关中断的 偶们老师上课根本就没提到这一块 那你怎么
知道的呢 就是说如果想提高自己钻研那么怎么样去寻找自己
需要的知识找到方向呢 谢谢指导

6 楼

C是一种经典的程序设计语言,可以这样说:"精通了C,就精通了任何编

程语言,它们只是形式不同,而思想却完全一样.".编程最重要的是思想

,而非写代码,如果仅仅想写一些程序代码,高中生即可胜任.当你精通

一门编程语言时,再想学其它语言时,可以在短短几天内掌握该语言,因

为它们的规则都差不多!只是有一些地方不同而已.
你想提高C水平,那就是多读别人的源代码,自己在写一些小程序.
我的资料是我一点一点积累的,学习的过程,其实是资料运用的过程,所

以必须会查找,收集资料.

7 楼

hotmail附件〈=1M的 是不是这个原因?希望能压缩一下再发一遍谢谢

我来回复

您尚未登录,请登录后再回复。点此登录或注册