37 lines
494 B
C
37 lines
494 B
C
#include <stdio.h>
|
|
#include <math.h>
|
|
#include <stdlib.h>
|
|
|
|
void int_to_char();
|
|
|
|
int main(){
|
|
int_to_char();
|
|
return 0;
|
|
}
|
|
|
|
void int_to_char(){
|
|
|
|
int num_text;
|
|
char *num_send;
|
|
int a;
|
|
int i;
|
|
int m;
|
|
int d;
|
|
num_send=(char *)malloc(4*sizeof(char));
|
|
printf("input num:\n");
|
|
scanf("%d",&num_text);
|
|
for(i=0;i<4;i++){
|
|
m=3-i;
|
|
for(d=1;m>0;){
|
|
d=d*10;
|
|
m--;
|
|
}
|
|
m=d;
|
|
a=num_text/m;
|
|
num_text=num_text-a*m;
|
|
num_send[i]=a+48;
|
|
}
|
|
printf("num_send is: %s\n",num_send);
|
|
free(num_send);
|
|
}
|