Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

563580 views
1
#include "typedef.h"
2
/**************************************************************************\
3
@---------------------------------------------------------------------------
4
@---------------------------------------------------------------------------
5
@ FILE: itoa.c
6
@---------------------------------------------------------------------------
7
@---------------------------------------------------------------------------
8
@
9
\**************************************************************************/
10
11
static void reverse(s)
12
char s[];
13
{
14
int c,i,j;
15
for(i=0, j=strlen(s)-1; i<j; i++, j--)
16
{
17
c = s[i];
18
s[i] = s[j];
19
s[j] = c;
20
}
21
}
22
23
24
25
/**************************************************************************\
26
@---------------------------------------------------------------------------
27
@ void itoa(n, s)
28
@ int n;
29
@ char s[];
30
@
31
@ changes the integer 'n' to a character 's', for example: 124 --> '124'
32
@---------------------------------------------------------------------------
33
@
34
\**************************************************************************/
35
void itoa(n, s)
36
int n;
37
char s[];
38
{
39
int i, sign;
40
if((sign = n) <0)
41
n = -n;
42
i=0;
43
do
44
{
45
s[i++] = n%10 + '0';
46
}while(( n /= 10) > 0);
47
if(sign < 0)
48
s[i++] = '-';
49
s[i] = '\0';
50
reverse(s);
51
}
52
53