小白每天学习两个函数D4-( strcat,itoa)

来源:互联网 发布:淘宝明星店铺 编辑:程序博客网 时间:2024/06/05 18:37
//////////////strcat/////////////////////////////////////////////////先加头文件#include<string.h>char a[10]="123"; char b[10]="abc"; strcat(a,b);        //连接两个字符串,连接后的字符串存放在a中,数组a中有足够空间 printf("%s",a);   //输出连接后的字符串或:#include<string.h>char a[10]="123";char b[10]="abc";char c[20];strcpy(c,a);            //把串a复制到有足够空间的c中strcat(c,b);        //把b连接到c的串尾//////////////////////itoa//////////////////////////////////////# include <stdio.h># include <stdlib.h>void main (void){int num = 100;char str[25];itoa(num, str, 10);printf("The number 'num' is %d and the string 'str' is %s. \n" ,num, str);}itoa()函数有3个参数:第一个参数是要转换的数字,第二个参数是要写入转换结果的目标字符串,第三个参数是转移数字时所用 的基数。在上例中,转换基数为1010:十进制;2:二进制...
阅读全文
0 0