| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> c/c++ >> C yu yan ku han shu (C lei zi mu )

C yu yan ku han shu (C lei zi mu )

2008-06-01 02:09:01 编辑來源:互联网 评论
 
 
 
本文为【C语言库函数 (C类字母)】的拼音翻译版
  [ fa biao ri qi :2002-1-4 9:28:46 ]
  han shu ming : cabs
  gong neng : ji suan fu shu de jue dui zhi
  yong fa : double cabs(strUCt complex z);
  cheng xu li :
  #include <stdio.h>
  #include <math.h>
  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;
  }
  han shu ming : calloc
  gong neng : fen pei zhu cun chu qi
  yong fa : void *calloc(size_t nelem, size_t elsize);
  cheng xu li :
  #include <stdio.h>
  #include <alloc.h>
  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;
  }
  han shu ming : ceil
  gong neng : xiang shang she ru
  yong fa : double ceil(double x);
  cheng xu li :
  #include <math.h>
  #include <stdio.h>
  int main(void)
  {
  double number = 123.54;
  double down, up;
  down = floor(number);
  up = ceil(number);
  printf("original number %5.2lf\n", number);
  printf("number rounded down %5.2lf\n", down);
  printf("number rounded up %5.2lf\n", up);
  return 0;
  }
  han shu ming : cgets
  gong neng : cong kong zhi tai du zi fu chuan
  yong fa : char *cgets(char *str);
  cheng xu li :
  #include <stdio.h>
  #include <conio.h>
  int main(void)
  {
  char buffer[83];
  char *p;
  /* There's space for 80 characters plus the NULL terminator */
  buffer[0] = 81;
  printf("Input some chars:");
  p = cgets(buffer);
  printf("\ncgets read %d characters: \"%s\"\n", buffer[1], p);
  printf("The returned pointer is %p, buffer[0] is at %p\n", p, &buffer);
  /* Leave room for 5 characters plus the NULL terminator */
  buffer[0] = 6;
  printf("Input some chars:");
  p = cgets(buffer);
  printf("\ncgets read %d characters: \"%s\"\n", buffer[1], p);
  printf("The returned pointer is %p, buffer[0] is at %p\n", p, &buffer);
  return 0;
  }
  han shu ming : chdir
  gong neng : gai bian gong zuo mu lu
  yong fa : int chdir(const char *path);
  cheng xu li :
  #include <stdio.h>
  #include <stdlib.h>
  #include <dir.h>
  char old_dir[MAXDIR];
  char new_dir[MAXDIR];
  int main(void)
  {
  if (getcurdir(0, old_dir))
  {
  perror("getcurdir()");
  exit(1);
  }
  printf("Current Directory is: \\%s\n", old_dir);
  if (chdir("\\"))
  {
  perror("chdir()");
  exit(1);
  }
  if (getcurdir(0, new_dir))
  
   {
  perror("getcurdir()");
  exit(1);
  }
  printf("Current directory is now: \\%s\n", new_dir);
  printf("\nChanging back to orignal directory: \\%s\n", old_dir);
  if (chdir(old_dir))
  {
  perror("chdir()");
  exit(1);
  }
  return 0;
  }
  han shu ming : _chmod, chmod
  gong neng : gai bian wen jian de fang wen fang shi
  yong fa : int chmod(const char *filename, int permiss);
  cheng xu li :
  #include <sys\stat.h>
  #include <stdio.h>
  #include <io.h>
  void make_read_only(char *filename);
  int main(void)
  {
  make_read_only("NOTEXIST.FIL");
  make_read_only("MYFILE.FIL");
  return 0;
  }
  void make_read_only(char *filename)
  {
  int stat;
  stat = chmod(filename, S_IREAD);
  if (stat)
  printf("Couldn't make %s read-only\n", filename);
  else
  printf("Made %s read-only\n", filename);
  }
  han shu ming : chsize
  gong neng : gai bian wen jian da xiao
  yong fa : int chsize(int handle, long size);
  cheng xu li :
  #include <string.h>
  #include <fcntl.h>
  #include <io.h>
  int main(void)
  {
  int handle;
  char buf[11] = "0123456789";
  /* create text file containing 10 bytes */
  handle = open("DUMMY.FIL", O_CREAT);
  write(handle, buf, strlen(buf));
  /* truncate the file to 5 bytes in size */
  chsize(handle, 5);
  /* close the file */
  close(handle);
  return 0;
  }
  han shu ming : circle
  gong neng : zai gei ding ban jing yi (x, y) wei yuan xin hua yuan
  yong fa : void far circle(int x, int y, int radius);
  cheng xu li :
  #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 radius = 100;
  /* 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;
  setcolor(getmaxcolor());
  /* draw the circle */
  circle(midx, midy, radius);
  /* clean up */
  getch();
  closegraph();
  return 0;
  }
  han shu ming : cleardevice
  gong neng : qing chu tu xing ping mu
  yong fa : void far cleardevice(void);
  cheng xu li :
  #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;
  /* 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;
  setcolor(getmaxcolor());
  /* for centering screen messages */
  settextjustify(CENTER_TEXT, CENTER_TEXT);
  /* output a message to the screen */
  outtextxy(midx, midy, "press any key to clear the screen:");
  /* wait for a key */
  getch();
  /* clear the screen */
  cleardevice();
  /* output another message */
  outtextxy(midx, midy, "press any key to quit:");
  /* clean up */
  getch();
  closegraph();
  return 0;
  }
  han shu ming : clearerr
  gong neng : fu wei cuo wu biao zhi
  yong fa :void clearerr(FILE *stream);
  cheng xu li :
  #include <stdio.h>
  int main(void)
  {
  FILE *fp;
  char ch;
  /* open a file for writing */
  fp = fopen("DUMMY.FIL", "w");
  /* force an error condition by attempting to read */
  ch = fgetc(fp);
  printf("%c\n",ch);
  if (ferror(fp))
  {
  /* display an error message */
  printf("Error reading from DUMMY.FIL\n");
  /* reset the error and EOF indicators */
  clearerr(fp);
  }
  fclose(fp);
  return 0;
  }
  han shu ming : clearviewport
  gong neng : qing chu tu xing shi qu
  yong fa : void far clearviewport(void);
  cheng xu li :
  #include <graphics.h>
  #include <stdlib.h>
  #include <stdio.h>
  #include <conio.h>
  #define CLIP_ON 1 /* activates clipping in viewport */
  int main(void)
  {
  /* request auto detection */
  int gdriver = DETECT, gmode, errorcode;
  int ht;
  /* 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 */
  }
  setcolor(getmaxcolor());
  ht = textheight("W");
  /* message in default full-screen viewport */
  outtextxy(0, 0, "* <-- (0, 0) in default viewport");
  /* create a smaller viewport */
  setviewport(50, 50, getmaxx()-50, getmaxy()-50, CLIP_ON);
  /* display some messages */
  outtextxy(0, 0, "* <-- (0, 0) in smaller viewport");
  outtextxy(0, 2*ht, "Press any key to clear viewport:");
  /* wait for a key */
  getch();
  /* clear the viewport */
  clearviewport();
  /* output another message */
  outtextxy(0, 0, "Press any key to quit:");
  /* clean up */
  getch();
  closegraph();
  return 0;
  }
  han shu ming : _close, close
  gong neng : guan bi wen jian ju bing
  yong fa : int close(int handle);
  cheng xu li :
  #include <string.h>
  #include <stdio.h>
  #include <fcntl.h>
  
   #include <io.h>
  main()
  {
  int handle;
  char buf[11] = "0123456789";
  /* create a file containing 10 bytes */
  handle = open("NEW.FIL", O_CREAT);
  if (handle > -1)
  {
  write(handle, buf, strlen(buf));
  /* close the file */
  close(handle);
  }
  else
  {
  printf("Error opening file\n");
  }
  return 0;
  }
  han shu ming : clock
  gong neng : que ding chu li qi shi jian
  yong fa : clock_t clock(void);
  cheng xu li :
  #include <time.h>
  #include <stdio.h>
  #include <dos.h>
  int main(void)
  {
  clock_t start, end;
  start = clock();
  delay(2000);
  end = clock();
  printf("The time was: %f\n", (end - start) / CLK_TCK);
  return 0;
  }
  han shu ming : closegraph
  gong neng : guan bi tu xing xi tong
  yong fa : void far closegraph(void);
  cheng xu li :
  #include <graphics.h>
  #include <stdlib.h>
  #include <stdio.h>
  #include <conio.h>
  int main(void)
  {
  /* request auto detection */
  int gdriver = DETECT, gmode, errorcode;
  int x, y;
  /* initialize graphics mode */
  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 */
  }
  x = getmaxx() / 2;
  y = getmaxy() / 2;
  /* output a message */
  settextjustify(CENTER_TEXT, CENTER_TEXT);
  outtextxy(x, y, "Press a key to close the graphics system:");
  /* wait for a key */
  getch();
  /* closes down the graphics system */
  closegraph();
  printf("We're now back in text mode.\n");
  printf("Press any key to halt:");
  getch();
  return 0;
  }
  han shu ming : clreol
  gong neng : zai wen ben chuang kou zhong qing chu zi fu dao xing mo
  yong fa : void clreol(void);
  cheng xu li :
  #include <conio.h>
  int main(void)
  {
  clrscr();
  cprintf("The function CLREOL clears all characters from the\r\n");
  cprintf("cursor position to the end of the line within the\r\n");
  cprintf("current text window, without moving the cursor.\r\n");
  cprintf("Press any key to continue . . .");
  gotoxy(14, 4);
  getch();
  clreol();
  getch();
  return 0;
  }
  han shu ming : clrscr
  gong neng : qing chu wen ben mo shi chuang kou
  yong fa : void clrscr(void);
  cheng xu li :
  #include <conio.h>
  int main(void)
  {
  int i;
  clrscr();
  for (i = 0; i < 20; i++)
  cprintf("%d\r\n", i);
  cprintf("\r\nPress any key to clear screen");
  getch();
  clrscr();
  cprintf("The screen has been cleared!");
  getch();
  return 0;
  }
  han shu ming : coreleft
  gong neng : fan hui wei shi yong nei cun de da xiao
  yong fa : unsigned coreleft(void);
  cheng xu li :
  #include <stdio.h>
  #include <alloc.h>
  int main(void)
  
   {
  printf("The difference between the highest allocated block and\n");
  printf("the top of the heap is: %lu bytes\n", (unsigned long) coreleft());
  return 0;
  }
  han shu ming : cos
  gong neng : yu xian han shu
  yong fa : double cos(double x);
  cheng xu li :
  #include <stdio.h>
  #include <math.h>
  int main(void)
  {
  double result;
  double x = 0.5;
  result = cos(x);
  printf("The cosine of %lf is %lf\n", x, result);
  return 0;
  }
  han shu ming : cosh
  gong neng : shuang qu yu xian han shu
  yong fa : dluble cosh(double x);
  cheng xu li :
  #include <stdio.h>
  #include <math.h>
  int main(void)
  {
  double result;
  double x = 0.5;
  result = cosh(x);
  printf("The hyperboic cosine of %lf is %lf\n", x, result);
  return 0;
  }
  han shu ming : country
  gong neng : fan hui yu guo jia you guan de xin xi
  yong fa : struct COUNTRY *country(int countrycode, struct country *country);
  cheng xu li :
  #include <dos.h>
  #include <stdio.h>
  #define USA 0
  int main(void)
  {
  struct COUNTRY country_info;
  country(USA, &country_info);
  printf("The currency symbol for the USA is: %s\n",
  country_info.co_curr);
  return 0;
  }
  han shu ming : cprintf
  gong neng : song ge shi hua shu chu zhi ping mu
  yong fa : int cprintf(const char *format[, argument, ...]);
  cheng xu li :
  #include <conio.h>
  int main(void)
  {
  /* clear the screen */
  clrscr();
  /* create a text window */
  window(10, 10, 80, 25);
  /* output some text in the window */
  cprintf("Hello world\r\n");
  /* wait for a key */
  getch();
  return 0;
  }
  han shu ming : cputs
  gong neng : xie zi fu dao ping mu
  yong fa : void cputs(const char *string);
  cheng xu li :
  #include <conio.h>
  int main(void)
  {
  /* clear the screen */
  clrscr();
  /* create a text window */
  window(10, 10, 80, 25);
  /* output some text in the window */
  cputs("This is within the window\r\n");
  /* wait for a key */
  getch();
  return 0;
  }
  han shu ming : _creat creat
  gong neng : chuang jian yi ge xin wen jian huo chong xie yi ge yi cun zai de wen jian
  yong fa : int creat (const char *filename, int permiss);
  cheng xu li :
  #include <sys\stat.h>
  #include <string.h>
  #include <fcntl.h>
  #include <io.h>
  int main(void)
  {
  int handle;
  char buf[11] = "0123456789";
  /* change the default file mode from text to binary */
  _fmode = O_BINARY;
  /* create a binary file for reading and writing */
  handle = creat("DUMMY.FIL", S_IREAD S_IWRITE);
  /* write 10 bytes to the file */
  write(handle, buf, strlen(buf));
  /* close the file */
  close(handle);
  return 0;
  }
  han shu ming : creatnew
  gong neng : chuang jian yi ge xin wen jian
  yong fa : int creatnew(const char *filename, int attrib);
  cheng xu li :
  #include <string.h>
  #include <stdio.h>
  #include <errno.h>
  #include <dos.h>
  
   #include <io.h>
  int main(void)
  {
  int handle;
  char buf[11] = "0123456789";
  /* attempt to create a file that doesn't already exist */
  handle = creatnew("DUMMY.FIL", 0);
  if (handle == -1)
  printf("DUMMY.FIL already exists.\n");
  else
  {
  printf("DUMMY.FIL successfully created.\n");
  write(handle, buf, strlen(buf));
  close(handle);
  }
  return 0;
  }
  han shu ming : creattemp
  gong neng : chuang jian yi ge xin wen jian huo chong xie yi ge yi cun zai de wen jian
  yong fa : int creattemp(const char *filename, int attrib);
  cheng xu li :
  #include <string.h>
  #include <stdio.h>
  #include <io.h>
  int main(void)
  {
  int handle;
  char pathname[128];
  strcpy(pathname, "\\");
  /* create a unique file in the root directory */
  handle = creattemp(pathname, 0);
  printf("%s was the unique file created.\n", pathname);
  close(handle);
  return 0;
  }
  han shu ming : cscanf
  gong neng : cong kong zhi tai zhi xing ge shi hua shu ru
  yong fa : int cscanf(char *format[,argument, ...]);
  cheng xu li :
  #include <conio.h>
  int main(void)
  {
  char string[80];
  /* clear the screen */
  clrscr();
  /* Prompt the user for input */
  cprintf("Enter a string with no spaces:");
  /* read the input */
  cscanf("%s", string);
  /* display what was read */
  cprintf("\r\nThe string entered is: %s", string);
  return 0;
  }
  han shu ming : ctime
  gong neng : ba ri qi he shi jian zhuan huan wei zi fu chuan
  yong fa : char *ctime(const time_t *time);
  cheng xu li :
  #include <stdio.h>
  #include <time.h>
  int main(void)
  {
  time_t t;
  time(&t);
  printf("Today's date and time: %s\n", ctime(&t));
  return 0;
  }
  han shu ming : ctrlbrk
  gong neng : she zhi Ctrl-Break chu li cheng xu
  yong fa : void ctrlbrk(*fptr)(void);
  cheng xu li :
  #include <stdio.h>
  #include <dos.h>
  #define ABORT 0
  int c_break(void)
  {
  printf("Control-Break pressed. Program aborting ...\n");
  return (ABORT);
  }
  int main(void)
  {
  ctrlbrk(c_break);
  for(;;)
  {
  printf("Looping... Press <Ctrl-Break> to quit:\n");
  }
  return 0;
  }【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
  [ fa biao ri qi :2002-1-4 9:28:46 ] han shu ming : cabs gong neng : ji suan fu shu de jue dui zhi yong fa : double cabs(strUCt complex z); cheng xu li : #include <stdio.h> #include <math.h> 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; } han shu ming : calloc gong neng : fen pei zhu cun chu qi yong fa : void *calloc(size_t nelem, size_t elsize); cheng xu li : #include <stdio.h> #include <alloc.h> 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; } han shu ming : ceil gong neng : xiang shang she ru yong fa : double ceil(double x); cheng xu li : #include <math.h> #include <stdio.h> int main(void) { double number = 123.54; double down, up; down = floor(number); up = ceil(number); printf("original number %5.2lf\n", number); printf("number rounded down %5.2lf\n", down); printf("number rounded up %5.2lf\n", up); return 0; } han shu ming : cgets gong neng : cong kong zhi tai du zi fu chuan yong fa : char *cgets(char *str); cheng xu li : #include <stdio.h> #include <conio.h> int main(void) { char buffer[83]; char *p; /* There's space for 80 characters plus the NULL terminator */ buffer[0] = 81; printf("Input some chars:"); p = cgets(buffer); printf("\ncgets read %d characters: \"%s\"\n", buffer[1], p); printf("The returned pointer is %p, buffer[0] is at %p\n", p, &buffer); /* Leave room for 5 characters plus the NULL terminator */ buffer[0] = 6; printf("Input some chars:"); p = cgets(buffer); printf("\ncgets read %d characters: \"%s\"\n", buffer[1], p); printf("The returned pointer is %p, buffer[0] is at %p\n", p, &buffer); return 0; } han shu ming : chdir gong neng : gai bian gong zuo mu lu yong fa : int chdir(const char *path); cheng xu li : #include <stdio.h> #include <stdlib.h> #include <dir.h> char old_dir[MAXDIR]; char new_dir[MAXDIR]; int main(void) { if (getcurdir(0, old_dir)) { perror("getcurdir()"); exit(1); } printf("Current Directory is: \\%s\n", old_dir); if (chdir("\\")) { perror("chdir()"); exit(1); } if (getcurdir(0, new_dir)) { perror("getcurdir()"); exit(1); } printf("Current directory is now: \\%s\n", new_dir); printf("\nChanging back to orignal directory: \\%s\n", old_dir); if (chdir(old_dir)) { perror("chdir()"); exit(1); } return 0; } han shu ming : _chmod, chmod gong neng : gai bian wen jian de fang wen fang shi yong fa : int chmod(const char *filename, int permiss); cheng xu li : #include <sys\stat.h> #include <stdio.h> #include <io.h> void make_read_only(char *filename); int main(void) { make_read_only("NOTEXIST.FIL"); make_read_only("MYFILE.FIL"); return 0; } void make_read_only(char *filename) { int stat; stat = chmod(filename, S_IREAD); if (stat) printf("Couldn't make %s read-only\n", filename); else printf("Made %s read-only\n", filename); } han shu ming : chsize gong neng : gai bian wen jian da xiao yong fa : int chsize(int handle, long size); cheng xu li : #include <string.h> #include <fcntl.h> #include <io.h> int main(void) { int handle; char buf[11] = "0123456789"; /* create text file containing 10 bytes */ handle = open("DUMMY.FIL", O_CREAT); write(handle, buf, strlen(buf)); /* truncate the file to 5 bytes in size */ chsize(handle, 5); /* close the file */ close(handle); return 0; } han shu ming : circle gong neng : zai gei ding ban jing yi (x, y) wei yuan xin hua yuan yong fa : void far circle(int x, int y, int radius); cheng xu li : #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 radius = 100; /* 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; setcolor(getmaxcolor()); /* draw the circle */ circle(midx, midy, radius); /* clean up */ getch(); closegraph(); return 0; } han shu ming : cleardevice gong neng : qing chu tu xing ping mu yong fa : void far cleardevice(void); cheng xu li : #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; /* 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; setcolor(getmaxcolor()); /* for centering screen messages */ settextjustify(CENTER_TEXT, CENTER_TEXT); /* output a message to the screen */ outtextxy(midx, midy, "press any key to clear the screen:"); /* wait for a key */ getch(); /* clear the screen */ cleardevice(); /* output another message */ outtextxy(midx, midy, "press any key to quit:"); /* clean up */ getch(); closegraph(); return 0; } han shu ming : clearerr gong neng : fu wei cuo wu biao zhi yong fa :void clearerr(FILE *stream); cheng xu li : #include <stdio.h> int main(void) { FILE *fp; char ch; /* open a file for writing */ fp = fopen("DUMMY.FIL", "w"); /* force an error condition by attempting to read */ ch = fgetc(fp); printf("%c\n",ch); if (ferror(fp)) { /* display an error message */ printf("Error reading from DUMMY.FIL\n"); /* reset the error and EOF indicators */ clearerr(fp); } fclose(fp); return 0; } han shu ming : clearviewport gong neng : qing chu tu xing shi qu yong fa : void far clearviewport(void); cheng xu li : #include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> #define CLIP_ON 1 /* activates clipping in viewport */ int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int ht; /* 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 */ } setcolor(getmaxcolor()); ht = textheight("W"); /* message in default full-screen viewport */ outtextxy(0, 0, "* <-- (0, 0) in default viewport"); /* create a smaller viewport */ setviewport(50, 50, getmaxx()-50, getmaxy()-50, CLIP_ON); /* display some messages */ outtextxy(0, 0, "* <-- (0, 0) in smaller viewport"); outtextxy(0, 2*ht, "Press any key to clear viewport:"); /* wait for a key */ getch(); /* clear the viewport */ clearviewport(); /* output another message */ outtextxy(0, 0, "Press any key to quit:"); /* clean up */ getch(); closegraph(); return 0; } han shu ming : _close, close gong neng : guan bi wen jian ju bing yong fa : int close(int handle); cheng xu li : #include <string.h> #include <stdio.h> #include <fcntl.h> #include <io.h> main() { int handle; char buf[11] = "0123456789"; /* create a file containing 10 bytes */ handle = open("NEW.FIL", O_CREAT); if (handle > -1) { write(handle, buf, strlen(buf)); /* close the file */ close(handle); } else { printf("Error opening file\n"); } return 0; } han shu ming : clock gong neng : que ding chu li qi shi jian yong fa : clock_t clock(void); cheng xu li : #include <time.h> #include <stdio.h> #include <dos.h> int main(void) { clock_t start, end; start = clock(); delay(2000); end = clock(); printf("The time was: %f\n", (end - start) / CLK_TCK); return 0; } han shu ming : closegraph gong neng : guan bi tu xing xi tong yong fa : void far closegraph(void); cheng xu li : #include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int x, y; /* initialize graphics mode */ 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 */ } x = getmaxx() / 2; y = getmaxy() / 2; /* output a message */ settextjustify(CENTER_TEXT, CENTER_TEXT); outtextxy(x, y, "Press a key to close the graphics system:"); /* wait for a key */ getch(); /* closes down the graphics system */ closegraph(); printf("We're now back in text mode.\n"); printf("Press any key to halt:"); getch(); return 0; } han shu ming : clreol gong neng : zai wen ben chuang kou zhong qing chu zi fu dao xing mo yong fa : void clreol(void); cheng xu li : #include <conio.h> int main(void) { clrscr(); cprintf("The function CLREOL clears all characters from the\r\n"); cprintf("cursor position to the end of the line within the\r\n"); cprintf("current text window, without moving the cursor.\r\n"); cprintf("Press any key to continue . . ."); gotoxy(14, 4); getch(); clreol(); getch(); return 0; } han shu ming : clrscr gong neng : qing chu wen ben mo shi chuang kou yong fa : void clrscr(void); cheng xu li : #include <conio.h> int main(void) { int i; clrscr(); for (i = 0; i < 20; i++) cprintf("%d\r\n", i); cprintf("\r\nPress any key to clear screen"); getch(); clrscr(); cprintf("The screen has been cleared!"); getch(); return 0; } han shu ming : coreleft gong neng : fan hui wei shi yong nei cun de da xiao yong fa : unsigned coreleft(void); cheng xu li : #include <stdio.h> #include <alloc.h> int main(void) { printf("The difference between the highest allocated block and\n"); printf("the top of the heap is: %lu bytes\n", (unsigned long) coreleft()); return 0; } han shu ming : cos gong neng : yu xian han shu yong fa : double cos(double x); cheng xu li : #include <stdio.h> #include <math.h> int main(void) { double result; double x = 0.5; result = cos(x); printf("The cosine of %lf is %lf\n", x, result); return 0; } han shu ming : cosh gong neng : shuang qu yu xian han shu yong fa : dluble cosh(double x); cheng xu li : #include <stdio.h> #include <math.h> int main(void) { double result; double x = 0.5; result = cosh(x); printf("The hyperboic cosine of %lf is %lf\n", x, result); return 0; } han shu ming : country gong neng : fan hui yu guo jia you guan de xin xi yong fa : struct COUNTRY *country(int countrycode, struct country *country); cheng xu li : #include <dos.h> #include <stdio.h> #define USA 0 int main(void) { struct COUNTRY country_info; country(USA, &country_info); printf("The currency symbol for the USA is: %s\n", country_info.co_curr); return 0; } han shu ming : cprintf gong neng : song ge shi hua shu chu zhi ping mu yong fa : int cprintf(const char *format[, argument, ...]); cheng xu li : #include <conio.h> int main(void) { /* clear the screen */ clrscr(); /* create a text window */ window(10, 10, 80, 25); /* output some text in the window */ cprintf("Hello world\r\n"); /* wait for a key */ getch(); return 0; } han shu ming : cputs gong neng : xie zi fu dao ping mu yong fa : void cputs(const char *string); cheng xu li : #include <conio.h> int main(void) { /* clear the screen */ clrscr(); /* create a text window */ window(10, 10, 80, 25); /* output some text in the window */ cputs("This is within the window\r\n"); /* wait for a key */ getch(); return 0; } han shu ming : _creat creat gong neng : chuang jian yi ge xin wen jian huo chong xie yi ge yi cun zai de wen jian yong fa : int creat (const char *filename, int permiss); cheng xu li : #include <sys\stat.h> #include <string.h> #include <fcntl.h> #include <io.h> int main(void) { int handle; char buf[11] = "0123456789"; /* change the default file mode from text to binary */ _fmode = O_BINARY; /* create a binary file for reading and writing */ handle = creat("DUMMY.FIL", S_IREAD S_IWRITE); /* write 10 bytes to the file */ write(handle, buf, strlen(buf)); /* close the file */ close(handle); return 0; } han shu ming : creatnew gong neng : chuang jian yi ge xin wen jian yong fa : int creatnew(const char *filename, int attrib); cheng xu li : #include <string.h> #include <stdio.h> #include <errno.h> #include <dos.h> #include <io.h> int main(void) { int handle; char buf[11] = "0123456789"; /* attempt to create a file that doesn't already exist */ handle = creatnew("DUMMY.FIL", 0); if (handle == -1) printf("DUMMY.FIL already exists.\n"); else { printf("DUMMY.FIL successfully created.\n"); write(handle, buf, strlen(buf)); close(handle); } return 0; } han shu ming : creattemp gong neng : chuang jian yi ge xin wen jian huo chong xie yi ge yi cun zai de wen jian yong fa : int creattemp(const char *filename, int attrib); cheng xu li : #include <string.h> #include <stdio.h> #include <io.h> int main(void) { int handle; char pathname[128]; strcpy(pathname, "\\"); /* create a unique file in the root directory */ handle = creattemp(pathname, 0); printf("%s was the unique file created.\n", pathname); close(handle); return 0; } han shu ming : cscanf gong neng : cong kong zhi tai zhi xing ge shi hua shu ru yong fa : int cscanf(char *format[,argument, ...]); cheng xu li : #include <conio.h> int main(void) { char string[80]; /* clear the screen */ clrscr(); /* Prompt the user for input */ cprintf("Enter a string with no spaces:"); /* read the input */ cscanf("%s", string); /* display what was read */ cprintf("\r\nThe string entered is: %s", string); return 0; } han shu ming : ctime gong neng : ba ri qi he shi jian zhuan huan wei zi fu chuan yong fa : char *ctime(const time_t *time); cheng xu li : #include <stdio.h> #include <time.h> int main(void) { time_t t; time(&t); printf("Today's date and time: %s\n", ctime(&t)); return 0; } han shu ming : ctrlbrk gong neng : she zhi Ctrl-Break chu li cheng xu yong fa : void ctrlbrk(*fptr)(void); cheng xu li : #include <stdio.h> #include <dos.h> #define ABORT 0 int c_break(void) { printf("Control-Break pressed. Program aborting ...\n"); return (ABORT); } int main(void) { ctrlbrk(c_break); for(;;) { printf("Looping... Press <Ctrl-Break> to quit:\n"); } return 0; }
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
情人节的清纯女生(9)
情人节的清纯女生(8)
情人节的清纯女生(7)
情人节的清纯女生(6)
山东蓬莱海边组照
一探哲蚌 II
一探哲蚌 III
古长城的一角
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有