Upload files to "string"
This commit is contained in:
45
string/typeConvert.c
Normal file
45
string/typeConvert.c
Normal file
@@ -0,0 +1,45 @@
|
||||
// this code is licenced under Wrathmark licence
|
||||
// © 2026 wullie wulliestudio.com
|
||||
// please see attached licence for full usage and rights
|
||||
|
||||
#include "string.h"
|
||||
|
||||
|
||||
// converts int to string
|
||||
const char *intCon(int number){
|
||||
int i = 0, isNegative = 0;
|
||||
static char string[34];
|
||||
|
||||
if(number < 0){
|
||||
isNegative = 1;
|
||||
number = -number;
|
||||
}
|
||||
while(number){
|
||||
string[i++] = (number % 10) + '0';
|
||||
number /= 10;
|
||||
}
|
||||
|
||||
if(isNegative){
|
||||
string[i++] = '-';
|
||||
}
|
||||
|
||||
string[i] = '\0';
|
||||
|
||||
int start = 0, end = i -1;
|
||||
while(start < end){
|
||||
char tempStr = string[start];
|
||||
string[start] = string[end];
|
||||
string[end] = tempStr;
|
||||
start ++;
|
||||
end --;
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
const char *floatCon(float number){
|
||||
int i = 0, isNegative = 0;
|
||||
static char string[32];
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user