第二基地

August 7, 2006

atoi?itoa?

Filed under: linux, program, C

atoi ()是库函数,用于把字符串转换成整数,实现起来相当容易,于是我傻乎乎地开始去找itoa,找了一圈,终于发现了,没有itoa啊
然后转念一想,要itoa做什么!真要的话自己写一个,几分钟的事情,但是现成的sprintf放这儿不用就真的傻了
而且sprintf显然更方便,因为它有转义字符可以控制输出的格式,于是结论:C语言哪里需要什么itoa嘛!

1 Comment »

The URI to TrackBack this entry is: http://prometheus.blogsome.com/2006/08/07/73/trackback/

  1. itoa

    原型:extern char *itoa(int i);

    用法:#include

    功能:把整数i转换成字符串

    说明:返回指向转换后的字符串的指针

    举例:

    // itoa.c

    #include
    #include

    main()
    {
    int i=7412;

    clrscr(); // clear screen
    textmode(0x00);

    printf(”%d”,i);
    printf(”%s”,itoa(i));

    getchar();
    return 0;
    }

    相关函数:无

    Comment by 沙罗 — January 31, 2007 @ 9:10 am

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>























Get free blog up and running in minutes with Blogsome | Theme designs available here