C语言库函数(五)

C语言库函数全面解读CHM版 C语言库函数是一组预先编写好的代码集合,这些函数封装了常见的功能,比如数据处理、数学计算、字符串操作等。程序员可以直接调用这些库函数,不必从头开始编写重复的代码,大大提高了开发效率。 阅读详情

函数名: setjmp 
功  能: 非局部转移 
用  法: int setjmp(jmp_buf env); 
程序例: 

#include <stdio.h> 
#include <process.h> 
#include <setjmp.h> 

void subroutine(void); 

jmp_buf jumper; 

int main(void) 
{ 
   int value; 

   value = setjmp(jumper); 
   if (value != 0) 
   { 
      printf("Longjmp with value %d/n", value); 
      exit(value); 
   } 
   printf("About to call subroutine ... /n"); 
   subroutine(); 
   return 0; 
} 

void subroutine(void) 
{ 
   longjmp(jumper,1); 
} 
  
  

函数名: setlinestyle 
功  能: 设置当前画线宽度和类型 
用  法: void far setlinestyle(int linestype, unsigned upattern); 
程序例: 

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

/* the names of the line styles supported */ 
char *lname[] = { 
   "SOLID_LINE", 
   "DOTTED_LINE", 
   "CENTER_LINE", 
   "DASHED_LINE", 
   "USERBIT_LINE" 
   }; 

int main(void) 
{ 
   /* request auto detection */ 
   int gdriver = DETECT, gmode, errorcode; 

   int style, midx, midy, userpat; 
   char stylestr[40]; 

   /* 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; 

   /* a user defined line pattern */ 
   /* binary: "0000000000000001"  */ 
   userpat = 1; 

   for (style=SOLID_LINE; style<=USERBIT_LINE; style++) 
   { 
      /* select the line style */ 
      setlinestyle(style, userpat, 1); 

      /* convert style into a string */ 
      strcpy(stylestr, lname[style]); 

      /* draw a line */ 
      line(0, 0, midx-10, midy); 

      /* draw a rectangle */ 
      rectangle(0, 0, getmaxx(), getmaxy()); 

      /* output a message */ 
      outtextxy(midx, midy, stylestr); 

      /* wait for a key */ 
      getch(); 
      cleardevice(); 
   } 

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

函数名: setmem 
功  能: 存值到存储区 
用  法: void setmem(void *addr, int len, char value); 
程序例: 

#include <stdio.h> 
#include <alloc.h> 
#include <mem.h> 

int main(void) 
{ 
   char *dest; 

   dest = calloc(21, sizeof(char)); 
   setmem(dest, 20, 'c'); 
   printf("%s/n", dest); 

   return 0; 
} 
  
  
  

函数名: setmode 
功  能: 设置打开文件方式 
用  法: int setmode(int handle, unsigned mode); 
程序例: 

#include <stdio.h> 
#include <fcntl.h> 
#include <io.h> 

int main(void) 
{ 
   int result; 

   result = setmode(fileno(stdprn), O_TEXT); 
   if (result == -1) 
      perror("Mode not available/n"); 
   else 
      printf("Mode successfully switched/n"); 
   return 0; 
} 
  
  
  

函数名: setpalette 
功  能: 改变调色板的颜色 
用  法: void far setpalette(int index, int actural_color); 
程序例: 

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

int main(void) 
{ 
   /* request auto detection */ 
   int gdriver = DETECT, gmode, errorcode; 
   int color, maxcolor, ht; 
   int y = 10; 
   char msg[80]; 

   /* 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 */ 
   } 

   maxcolor = getmaxcolor(); 
   ht = 2 * textheight("W"); 

   /* display the default colors */ 
   for (color=1; color<=maxcolor; color++) 
   { 
      setcolor(color); 
      sprintf(msg, "Color: %d", color); 
      outtextxy(1, y, msg); 
      y += ht; 
   } 

   /* wait for a key */ 
   getch(); 

   /* black out the colors one by one */ 
   for (color=1; color<=maxcolor; color++) 
   { 
      setpalette(color, BLACK); 
      getch(); 
   } 

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

函数名: setrgbpalette 
功  能: 定义IBM8514图形卡的颜色 
用  法: void far setrgbpalette(int colornum, int red, int green, int blue); 
程序例: 

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

int main(void) 
{ 
   /* select a driver and mode that supports the use */ 
   /* of the setrgbpalette function.                 */ 
   int gdriver = VGA, gmode = VGAHI, errorcode; 
   struct palettetype pal; 
   int i, ht, y, xmax; 

   /* 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 */ 
   } 

   /* grab a copy of the palette */ 
   getpalette(&pal); 

   /* create gray scale */ 
   for (i=0; i<pal.size; i++) 
      setrgbpalette(pal.colors[i], i*4, i*4, i*4); 

   /* display the gray scale */ 
   ht = getmaxy() / 16; 
   xmax = getmaxx(); 
   y = 0; 
   for (i=0; i<pal.size; i++) 
   { 
      setfillstyle(SOLID_FILL, i); 
      bar(0, y, xmax, y+ht); 
      y += ht; 
   } 

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

函数名: settextjustify 
功  能: 为图形函数设置文本的对齐方式 
用  法: void far settextjustify(int horiz, int vert); 
程序例: 

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

/* function prototype */ 
void xat(int x, int y); 

/* horizontal text justification settings */ 
char *hjust[] = { "LEFT_TEXT", 
                  "CENTER_TEXT", 
                  "RIGHT_TEXT" 
                }; 

/* vertical text justification settings */ 
char *vjust[] = { "LEFT_TEXT", 
    "CENTER_TEXT", 
    "RIGHT_TEXT" 
                }; 

int main(void) 
{ 
   /* request auto detection */ 
   int gdriver = DETECT, gmode, errorcode; 
   int midx, midy, hj, vj; 
   char msg[80]; 

   /* 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 text justifications */ 
   for (hj=LEFT_TEXT; hj<=RIGHT_TEXT; hj++) 
      for (vj=LEFT_TEXT; vj<=RIGHT_TEXT; vj++) 
      { 
         cleardevice(); 
         /* set the text justification */ 
         settextjustify(hj, vj); 

         /* create a message string */ 
         sprintf(msg, "%s  %s", hjust[hj], vjust[vj]); 

  /* create cross hairs on the screen */ 
  xat(midx, midy); 

         /* output the message */ 
         outtextxy(midx, midy, msg); 
         getch(); 
      } 

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

/* draw an "x" at (x, y) */ 
void xat(int x, int y) 
{ 
  line(x-4, y, x+4, y); 
  line(x, y-4, x, y+4); 
} 
  
  

函数名: settextstyle 
功  能: 为图形输出设置当前的文本属性 
用  法: void far settextstyle (int font, int direction, char size); 
程序例: 

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

/* the names of the text styles supported */ 
char *fname[] = { "DEFAULT font", 
                  "TRIPLEX font", 
                  "SMALL font", 
                  "SANS SERIF font", 
                  "GOTHIC font" 
                }; 

int main(void) 
{ 
   /* request auto detection */ 
   int gdriver = DETECT, gmode, errorcode; 
   int style, midx, midy; 
   int size = 1; 

   /* 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; 

   settextjustify(CENTER_TEXT, CENTER_TEXT); 

   /* loop through the available text styles */ 
   for (style=DEFAULT_FONT; style<=GOTHIC_FONT; style++) 
   { 
      cleardevice(); 
      if (style == TRIPLEX_FONT) 
         size = 4; 

      /* select the text style */ 
      settextstyle(style, HORIZ_DIR, size); 

      /* output a message */ 
      outtextxy(midx, midy, fname[style]); 
      getch(); 
   } 

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

函数名: settextstyle 
功  能: 为图形输出设置当前的文本属性 
用  法: void far settextstyle (int font, int direction, char size); 
程序例: 

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

/* the names of the text styles supported */ 
char *fname[] = { "DEFAULT font", 
                  "TRIPLEX font", 
                  "SMALL font", 
                  "SANS SERIF font", 
                  "GOTHIC font" 
                }; 

int main(void) 
{ 
   /* request auto detection */ 
   int gdriver = DETECT, gmode, errorcode; 
   int style, midx, midy; 
   int size = 1; 

   /* 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; 

   settextjustify(CENTER_TEXT, CENTER_TEXT); 

   /* loop through the available text styles */ 
   for (style=DEFAULT_FONT; style<=GOTHIC_FONT; style++) 
   { 
      cleardevice(); 
      if (style == TRIPLEX_FONT) 
         size = 4; 

      /* select the text style */ 
      settextstyle(style, HORIZ_DIR, size); 

      /* output a message */ 
      outtextxy(midx, midy, fname[style]); 
      getch(); 
   } 

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

函数名: settime 
功  能: 设置系统时间 
用  法: void settime(struct time *timep); 
程序例: 

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

int main(void) 
{ 
   struct  time t; 

   gettime(&t); 
   printf("The current minute is: %d/n", t.ti_min); 
   printf("The current hour is: %d/n", t.ti_hour); 
   printf("The current hundredth of a second is: %d/n", t.ti_hund); 
   printf("The current second is: %d/n", t.ti_sec); 

   /* Add one to the minutes struct element and then call settime  */ 
   t.ti_min++; 
   settime(&t); 

   return 0; 
} 
  
  

函数名: setusercharsize 
功  能: 为矢量字体改变字符宽度和高度 
用  法: void far setusercharsize(int multx, int dirx, int multy, int diry); 
程序例: 

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

int main(void) 
{ 
   /* request autodetection */ 
   int gdriver = DETECT, gmode, errorcode; 

   /* 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 */ 
   } 

   /* select a text style */ 
   settextstyle(TRIPLEX_FONT, HORIZ_DIR, 4); 

   /* move to the text starting position */ 
   moveto(0, getmaxy() / 2); 

   /* output some normal text */ 
   outtext("Norm "); 

   /* make the text 1/3 the normal width */ 
   setusercharsize(1, 3, 1, 1); 
   outtext("Short "); 

   /* make the text 3 times normal width */ 
   setusercharsize(3, 1, 1, 1); 
   outtext("Wide"); 

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

函数名: setvbuf 
功  能: 把缓冲区与流相关 
用  法: int setvbuf(FILE *stream, char *buf, int type, unsigned size); 
程序例: 

#include <stdio.h> 

int main(void) 
{ 
   FILE *input, *output; 
   char bufr[512]; 

   input = fopen("file.in", "r+b"); 
   output = fopen("file.out", "w"); 

   /* set up input stream for minimal disk access, 
      using our own character buffer */ 
   if (setvbuf(input, bufr, _IOFBF, 512) != 0) 
      printf("failed to set up buffer for input file/n"); 
   else 
      printf("buffer set up for input file/n"); 

   /* set up output stream for line buffering using space that 
      will be obtained through an indirect call to malloc */ 
   if (setvbuf(output, NULL, _IOLBF, 132) != 0) 
      printf("failed to set up buffer for output file/n"); 
   else 
      printf("buffer set up for output file/n"); 

   /* perform file I/O here */ 

   /* close files */ 
   fclose(input); 
   fclose(output); 
   return 0; 
} 
  
  
  

函数名: setvect 
功  能: 设置中断矢量入口 
用  法: void setvect(int intr_num, void interrupt(*isr)()); 
程序例: 

/***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> 

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

void interrupt ( *oldhandler)(void); 

int count=0; 

void interrupt handler(void) 
{ 
/* increase the global counter */ 
   count++; 

/* 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; 
} 
  
  

函数名: setverify 
功  能: 设置验证状态 
用  法: void setverify(int value); 
程序例: 

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

int main(void) 
{ 
   int verify_flag; 

   printf("Enter 0 to set verify flag off/n"); 
   printf("Enter 1 to set verify flag on/n"); 

   verify_flag = getch() - 0; 

   setverify(verify_flag); 

   if (getverify()) 
      printf("DOS verify flag is on/n"); 
   else 
      printf("DOS verify flag is off/n"); 

   return 0; 
} 
  
  

函数名: setviewport 
功  能: 为图形输出设置当前视口 
用  法: void far setviewport(int left, int top, int right, 
        int bottom, int clipflag); 
程序例: 

#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; 

   /* 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()); 

   /* 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 text */ 
   outtextxy(0, 0, "* <-- (0, 0) in smaller viewport"); 

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

函数名: setvisualpage 
功  能: 设置可见图形页号 
用  法: void far setvisualpage(int pagenum); 
程序例: 

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

int main(void) 
{ 
   /* select a driver and mode that supports */ 
   /* multiple pages.                        */ 
   int gdriver = EGA, gmode = EGAHI, errorcode; 
   int x, y, 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 */ 
   } 

   x = getmaxx() / 2; 
   y = getmaxy() / 2; 
   ht = textheight("W"); 

   /*  select the off screen page for drawing */ 
   setactivepage(1); 

   /* draw a line on page #1 */ 
   line(0, 0, getmaxx(), getmaxy()); 

   /* output a message on page #1 */ 
   settextjustify(CENTER_TEXT, CENTER_TEXT); 
   outtextxy(x, y, "This is page #1:"); 
   outtextxy(x, y+ht, "Press any key to halt:"); 

   /* select drawing to page #0 */ 
   setactivepage(0); 

   /* output a message  on page #0 */ 
   outtextxy(x, y, "This is page #0."); 
   outtextxy(x, y+ht, "Press any key to view page #1:"); 
   getch(); 

   /* select page #1 as the visible page */ 
   setvisualpage(1); 

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

函数名: setwritemode 
功  能: 设置图形方式下画线的输出模式 
用  法: void far setwritemode(int mode); 
程序例: 

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

int main() 
{ 
   /* request auto detection */ 
   int gdriver = DETECT, gmode, errorcode; 
   int xmax, ymax; 

   /* 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 */ 
   } 

   xmax = getmaxx(); 
   ymax = getmaxy(); 

   /* select XOR drawing mode */ 
   setwritemode(XOR_PUT); 

   /* draw a line */ 
   line(0, 0, xmax, ymax); 
   getch(); 

   /* erase the line by drawing over it */ 
   line(0, 0, xmax, ymax); 
   getch(); 

   /* select overwrite drawing mode */ 
   setwritemode(COPY_PUT); 

   /* draw a line */ 
   line(0, 0, xmax, ymax); 

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

函数名: signal 
功  能: 设置某一信号的对应动作 
用  法: int signal(int sig, sigfun fname); 
程序例: 

/* This example installs a signal handler routine for SIGFPE, 
   catches an integer overflow condition, makes an adjustment 
   to AX register, and returns. This example program MAY cause 
   your computer to crash, and will produce runtime errors 
   depending on which memory model is used. 
*/ 

#pragma inline 
#include <stdio.h> 
#include <signal.h> 

void Catcher(int sig, int type, int *reglist) 
{ 
   printf("Caught it!/n"); 
   *(reglist + 8) = 3;             /* make return AX = 3 */ 
} 

int main(void) 
{ 
   signal(SIGFPE, Catcher); 
   asm     mov     ax,07FFFH       /* AX = 32767 */ 
   asm     inc     ax              /* cause overflow */ 
   asm     into                    /* activate handler */ 

   /* The handler set AX to 3 on return. If that hadn't happened, 
      there would have been another exception when the next 'into' 
      was executed after the 'dec' instruction. */ 
   asm     dec     ax              /* no overflow now */ 
   asm     into                    /* doesn't activate */ 
   return 0; 
} 
  
  
  

函数名: sin 
功  能: 正弦函数 
用  法: double sin(double x); 
程序例: 

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

int main(void) 
{ 
   double result, x = 0.5; 

   result = sin(x); 
   printf("The sin() of %lf is %lf/n", x, result); 
   return 0; 
} 
  
  

函数名: sinh 
功  能: 双曲正弦函数 
用  法: double sinh(double x); 
程序例: 

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

int main(void) 
{ 
   double result, x = 0.5; 

   result = sinh(x); 
   printf("The hyperbolic sin() of %lf is %lf/n", x, result); 
   return 0; 
} 
  
  
  

函数名: sleep 
功  能: 执行挂起一段时间 
用  法: unsigned sleep(unsigned seconds); 
程序例: 

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

int main(void) 
{ 
   int i; 

   for (i=1; i<5; i++) 
   { 
      printf("Sleeping for %d seconds/n", i); 
      sleep(i); 
   } 
   return 0; 
} 
  
  
  

函数名: sopen 
功  能: 打开一共享文件 
用  法: int sopen(char *pathname, int access, int shflag, int permiss); 
程序例: 

#include <io.h> 
#include <fcntl.h> 
#include <sys/stat.h> 
#include <process.h> 
#include <share.h> 
#include <stdio.h> 

int main(void) 
{ 
   int handle; 
   int status; 

   handle = sopen("c://autoexec.bat", O_RDONLY, SH_DENYNO, S_IREAD); 

   if (!handle) 
   { 
      printf("sopen failed/n"); 
      exit(1); 
   } 

   status = access("c://autoexec.bat", 6); 
   if (status == 0) 
      printf("read/write access allowed/n"); 
   else 
      printf("read/write access not allowed/n"); 

   close(handle); 
   return 0; 
} 

C语言库函数大全与实战应用 本文还有配套的精品资源,点击获取 简介:C语言库函数是编程中不可或缺的工具,提供了标准输入输出、数学计算、字符串操作、内存管理、错误处理等基础功能。掌握这些库函数对每个C程序员而言是基本要求。本文详细介绍了输入输出、数学、字符串处理、内存管理、错误处理等领域的常用函数及其用法,同时强调了理解参数、返回值和潜在错误的重要性。通过熟悉标准库头文件和实践应用,可以有效提升编程效率... 阅读详情

相关推荐

C语言库函数手册及查询技巧

在C语言的编程实践中,库函数是构成程序的重要组成部分,它们为开发者提供了一系列经过高度优化的现成代码,用于执行各种常见的任务。库函数简化了编程过程,提高了开发效率,并且有助于代码的维护与复用。C语言库函数是一组封装好的代码,它们按照特定的功能被组织起来,存储在可被链接的库文件中。这些函数大致可以分为标准库函数和非标准库函数两大类。标准库函数是C标准定义的,包含输入输出、字符串处理、内存管理等核心功能,而非标准库函数则是特定于平台或编译器的扩展函数。

weixin_29155599的博客 740

打印图示比例图形c语言,C语言图形编程(四、图形文本-01)

一、图形文本函数85. outtext() 当前位置显示字符串函数86. outtextxy() 在(x,y)处显示字符串函数87. sprintf() 格式化输出函数二、图形文本设置88. settextstyle() 设置文本型式函数89. settextjustify() 设置文本排齐函数90. setusercharsize() 设置用户字符比例函数91. gettextsettings(...

weixin_42511832的博客 547

LAP-D协议概述

Q.921协议由称为LAPD(链路访问协议-D通道),与HDLC的关系密切,它是在ISDN D通道上使用的数据链路协议。 注:http://www.freesoft.org/CIE/Topics/125.htm LAP-D的帧格式 标志、位填充技术和FCS校验计算与HDLC一致。 16位的地址包括C/R字段、SAPI(服务访问点标识)和TEI(端点标识)。TEI用于区分使用相同ISDN...

系统运维 1914

C语言图形函数

C语言图形函数                                       1.1 C 语言的产生与发展     C 语言是1972年由美国的Dennis Ritchie设计发明的, 并首次在UNIX操作系统 的 DEC  PDP-11  计算机上使用。  它由早期的编程语言 BCPL( Basic   Combind Programming Language) 发

kiss0kill的专栏 8425

从配置字到实际运动:手把手教你用EtherCAT调试伺服电机的控制模式(以倍福TwinCAT3为例)

本文详细介绍了如何使用EtherCAT调试伺服电机的控制模式,以倍福TwinCAT3为例。从环境搭建、模式配置到状态机切换,提供了完整的操作指南和典型故障排查方法,帮助工程师快速解决‘配置字写入了但电机不转’等常见问题,提升工业自动化现场的调试效率。

weixin_42783709的博客 421

Box2D-Lite源码阅读笔记(2)

0.初始化函数 static void InitDemo(int index) { world.Clear(); numBodies = 0; numJoints = 0; bomb = NULL; demoIndex = index; demos[index](bodies, joints); } 在这个初始化函数中,一般会默认执行index=0的函数,这个函数就是一个示例,因为示例比较简单,所以也便于研究,示例效果如下。 就是一个方块。 进入第一个示例函数。(忽略我加的注释)

ARTELE的博客 976

Linux C语言常用函数 06

  函数名: setbkcolor   功  能: 用调色板设置当前背景颜色   用  法: void far setbkcolor(int color);   程序例:   #include ;   #include ;   #include ;   #include ;   int main(void)   {      /* select a driver and mo...

wangleide414的专栏 342

Arduino IDE 2配置ESP32-S3工程全指南

嵌入式开发中,Arduino框架通过硬件抽象层(HAL)大幅降低MCU入门门槛,其核心在于板级支持包(BSP)与底层构建系统(如ESP-IDF)的精准协同。理解CPU频率、Flash模式、分区表、PSRAM等关键配置,本质是掌握SoC时钟树、SPI Flash通信协议、内存映射与FreeRTOS调度机制的技术原理。这些参数不仅决定固件能否启动,更直接影响功耗、实时性、OTA升级与大容量应用(如LVGL、TFLite Micro)的可行性。本文以ESP32-S3为例,聚焦Arduino IDE 2.x环境下从

root9的博客 783

EGE基础入门篇(四):窗口简单操作

EGE窗口的一些设置位置和大小的简单操作

依稀_yixy的博客 1万+

激光除草技术原理与应用全解析

激光除草技术通过光热、光化学等效应精准破坏杂草组织,核心参数包括功率(20-6000W)、波长(400nm-10.6μm)和脉冲宽度。主要应用于大田作物(如玉米、棉花)、经济作物(烟草、果树)及城市绿化,具有环保(无化学污染)、高效(识别率≥95%)和非接触等优势,但存在设备成本高(20-50万元)、技术门槛高等局限。当前技术融合AI识别、多光谱协同等创新,国产设备如华工智耘已实现95.3%识别精度。虽短期投入较高,但长期可降低30%除草成本,并带来环境效益(每亩减排1.2吨CO₂)

start_up_go的博客 557

Windows上MSYS2的安装和使用

MSYS2这个工具我是越用越喜欢,很多东西放在Linux上如鱼得水但是放在Windows上就没那么好用,比如ffmpeg,opencv等直接引用就行了,这个工具真的很省事。接下来带你们看看它的妙用。1、好好研究确实妙用无穷。

jiexijihe945的博客 4142

[转]C语言图形编程(四) -图形文本

一、图形文本函数    85. outtext() 当前位置显示字符串函数    86. outtextxy() 在(x,y)处显示字符串函数    87. sprintf() 格式化输出函数二、图形文本设置    88. settextstyle() 设置文本型式函数    89. settextjustify() 设置文本排齐函数    90. setusercharsize() 设置用户字符

sky2098的专栏 4868

决策变量乘积项的线性化

介绍了决策变量相乘情况下的线性化,并用案例进行线性化演示,其中针对连续变量相乘的情况介绍了McCormick包络的近似线性化方法

Linshaodan520的博客 1845

C语言库函数大全及应用实例五

C语言库函数大全及应用实例五 原文:C语言库函数大全及应用实例五 [编程资料]C语言库函数大全及应用实例五 函数名: getcurdir 功 能: 取指定驱动器的当前目录 用 法: int getcurdir(int drive, char *d...

weixin_30782293的博客 342

14、方法论 - 自顶向下与自底向上的结合

本文探讨了如何将自顶向下的规范驱动方法与自底向上的组件构建方法相结合,以形成更加全面的编程理论。通过引入代数法则,简化逻辑关系、提高代码可读性并支持形式化验证,结合实际案例(如智能家居控制系统)展示了如何在设计和实现阶段确保系统的正确性和可靠性。文章还讨论了工具支持的重要性,并提出了未来发展的方向。

lstm7chronicler的博客 176

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

C语言库函数— qsort () 详解

C语言库函数qsort()详细介绍

qq_74009838的博客 1万+

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

C语言库函数

函数说明:每一个打开的文件都有一个读写位置,当打开文件时通常其读写位置是指向文件开头,若是以附加的方式打开文件(如 O_APPEND),则读写位置会指向文件尾。当read()或wirte()时,读写位置会随之增加,lseek()便是用来控制文件的读写位置。// 目录文件内部偏移。// 权限0777(完全开放)// 目录项缓冲区(通常4KB)mode_t st_mode;// 文件类型和权限位。// 文件大小(字节)

weixin_55608863的博客 2328

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

C语言库函数查找工具MSDN

一、前言 库函数在我们写程序的时候会在很大程度上提高我们的效率,我知道很多人可能像我一样,很多时候并不是不知道可以用库函数来实现,但就是不知道库函数如何使用,所以今天呢博主就来推荐资源了——C语言库函数查找工具《MSDN》(百度网盘提取码:MSDN),后面将会演示如何使用的,同时博客还给大家推荐一些链接,也可以查看的:推荐大家使用英文版的,看不懂也可以用谷歌翻译哟 cplusplus.com zh.cppreference.com 二、MSDN 函数搜索 函数的介绍 关于get

qq_47799626的博客 5616

【免费下载】 C语言库函数查询手册资源下载

C语言库函数查询手册资源下载 【下载地址】C语言库函数查询手册资源下载 本仓库提供了一个C语言库函数查询手册的资源文件下载,文件名为 `C语言库函数查询手册.chm`。该资源文件是一个压缩包,内含以下六个CHM格式的手册:1. **C参考手册.chm** - 最全面的一个手册,涵盖了C语言的各个方面。2. **C函数查询...

gitblog_09819的博客 1485

查看C语言库函数源码

C语言库函数源码哪里看?这里看!

火红色祥云 5574

c语言中min函数的作用,C语言库函数

C语言库函数是把自定义函数放到库里,是别人把一些常用到的函数编完放到一个文件里,供程序员使用。程序员用的时候把它所在的文件名用#include<>加到里面就可以了(尖括号内填写文件名),例如#include。中文名C语言库函数C语言库函数定义编辑一般是指编译器提供的可在c源程序中调用的函数。可分为两类,一类是c语言标准规定的库函数,一类是编译器特定的库函数。由于版权原因,库函数的源代码...

weixin_39680678的博客 3022

c语言函数库入门,C语言库函数

C语言库函数是把自定义函数放到库里,是别人把一些常用到的函数编完放到一个文件里,供程序员使用。程序员用的时候把它所在的文件名用#include<>加到里面就可以了(尖括号内填写文件名),例如#include。中文名C语言库函数C语言库函数定义编辑一般是指编译器提供的可在c源程序中调用的函数。可分为两类,一类是c语言标准规定的库函数,一类是编译器特定的库函数。由于版权原因,库函数的源代码...

weixin_30420799的博客 1089
上一篇: C语言库函数(四)
下一篇: C语言库函数(六)
liu0013
博客等级 码龄22年 5粉丝 14原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值