Browse Source

implementation of to_string()

remotes/origin/feature/string-handling
fdai7057 2 years ago
parent
commit
77e31ad441
  1. 5
      build-project.sh
  2. 5
      src/CustomerProperties.h
  3. 24
      src/StringManipulation.c
  4. 3
      src/StringManipulation.h
  5. 7
      src/main.c
  6. 9
      team.md

5
build-project.sh

@ -1,5 +0,0 @@
clear
cd src/
gcc main.c
./a.out
rm a.out

5
src/CustomerProperties.h

@ -0,0 +1,5 @@
typedef struct Customer{
int ID;
char *forename,*surname,*password;
float balance;
}customer_t;

24
src/StringManipulation.c

@ -0,0 +1,24 @@
#include "StringManipulation.h"
/*Code written by Julius Philipp Engel, fdai7057*/
char *to_string(int number)
{
if(number==0)
{
return "0\0";
}
else
{
int cpy = number, len = 0;
while(number>0){
++len;
number /= 10;
}
char *str = calloc(len+1, sizeof(char));
for(int i=0,j=len-1;i<len;++i,--j){
*(str+j) = '0' + (cpy % 10);
cpy /= 10;
}
*(str+len) = '\0';
return str;
}
}

3
src/StringManipulation.h

@ -0,0 +1,3 @@
#include <stdlib.h>
#include <stdio.h>
char *to_string(int);

7
src/main.c

@ -1,7 +0,0 @@
#include <stdio.h>
int main()
{
return 0;
}

9
team.md

@ -1,9 +0,0 @@
# Bankmanagement-System
- Can Hacioglu, Fdlt3817
- Atharva Kishor Naik, fdai7514
- Julius Philipp Engel, fdai7057
- Shivam Chaudhary, fdlt3781
- Mohamed Yahya Dahi, fdai6618
- Haytham Daoula, fdai7207
Loading…
Cancel
Save