把一个整数转换成字符串,并倒序保存在字符数组s中--简单算法

源程序:

#include <stdio.h>

#include <stdlib.h>

#define N 80

char s[N];

void fun(long int n) 

{

  int i = 0;

  while (n > 0)

  {

    s[i] = n % 10 + '0';

    n = n / 10;

    i++;

  }

  s[i] = '';

}

void main()

{

  long int n = 12345;

  printf("***the origial data*** ");

  printf("n=%ld",n);

  fun(n);

  printf(" %s",s);

  system("pause");

}

  

原文地址:https://www.cnblogs.com/duanqibo/p/11887050.html