⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myint.c

📁 压缩包里面的都是精致的基本C语言小程序
💻 C
字号:
#include <stdio.h>#include <stdlib.h>#include "mystdlib.h"#include "error.h"#include "myint.h"static int maxSize = 1000;struct myint{  int i;};myint newMyint (int i){  myint mi = checkedMalloc (sizeof (*mi));  mi->i = i;  return mi;}str intToString2 (int n){  char a[100];  int temp[100];  int size = -1;    char sign = '+';  if (n < 0)    sign = '-';  int absn = abs (n);  int mod = 0;  while (absn > 9)  {    mod = absn % 10;    absn = absn / 10;    temp[++size] = mod;  }    if (absn>=0)    temp [++size] = absn;    //for (int t=0; t<=size; t++)  //printf ("size=%d, %d\n", size, temp[t]);  if ('-'==sign)  {    for (int j=size; j>=0; j--)      a[size-j+1] = temp[j] + 48;    a[0] = '-';    a[size+2] = '\0';  }  else  {    for (int j=size; j>=0; j--)      a[size-j] = temp[j] + 48;    a[size+1] = '\0';  }    return newStr (a);}str intToString (long i){  char *temp;  temp = checkedMalloc (maxSize * sizeof (char));  sprintf (temp, "%ld", i);  if (! (strValid (temp, maxSize)))    exception ("space not enought: myint.c\n");    str sss = newStr (temp);  checkedFree (temp);  return sss;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -