[C] 返回一个错误信息串的指针 →→→→→进入此内容的聊天室

来自 , 2020-11-22, 写在 C, 查看 99 次.
URL http://www.code666.cn/view/04ad5632
  1. #include <graphics.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <conio.h>
  5.  
  6. #define NONSENSE -50
  7.  
  8. int main(void)
  9. {
  10.    /* FORCE AN ERROR TO OCCUR */
  11.    int gdriver = NONSENSE, gmode, errorcode;
  12.  
  13.    /* initialize graphics mode */
  14.    initgraph(&gdriver, &gmode, "");
  15.  
  16.    /* read result of initialization */
  17.    errorcode = graphresult();
  18.  
  19.    /* if an error occurred, then output a */
  20.    /* descriptive error message.          */
  21.    if (errorcode != grOk)
  22.    {
  23.       printf("Graphics error: %s\n", grapherrormsg(errorcode));
  24.       printf("Press any key to halt:");
  25.       getch();
  26.       exit(1); /* terminate with an error code */
  27.    }
  28.  
  29.    /* draw a line */
  30.    line(0, 0, getmaxx(), getmaxy());
  31.  
  32.    /* clean up */
  33.    getch();
  34.    closegraph();
  35.    return 0;
  36. }
  37.  

回复 "返回一个错误信息串的指针"

这儿你可以回复上面这条便签

captcha