mirror of
https://github.com/arcan1s/moldyn.git
synced 2025-07-12 21:35:51 +00:00
Added Makefile
Added lib 'int2str.c' Added 'main.c'
This commit is contained in:
26
stat_new/int2str.c
Normal file
26
stat_new/int2str.c
Normal file
@ -0,0 +1,26 @@
|
||||
/* Library for converting integer to string
|
||||
* Usage
|
||||
* char = conv (number, position)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
char conv (int fnumb, int dig_pos)
|
||||
/* fnumb - integer
|
||||
* dig_pos - position
|
||||
*/
|
||||
{
|
||||
int d, h, o;
|
||||
char const digit[] = "0123456789";
|
||||
|
||||
h = fnumb / 100;
|
||||
d = (fnumb % 100) / 10;
|
||||
o = fnumb % 10;
|
||||
|
||||
if (dig_pos == 1) return digit[o];
|
||||
if (dig_pos == 2) return digit[d];
|
||||
if (dig_pos == 3) return digit[h];
|
||||
else return digit[0];
|
||||
}
|
Reference in New Issue
Block a user