一、数组清空
# include <stdio.h>
# include <string.h>
int main(void)
{
int i,j;
char str[11]={"1122334455"};
for (j=0; j<10; ++j)
{
printf("%c", str[j]);
}
printf("\n");
memset(str, 0, sizeof(str)); //数组清空
for (i=0; i<500; ++i)
{
printf("%c", str[i]); //此时str的值是0000000000
}
}
二、char类型转换int类型
#include <stdlib.h> //需要头文件stdlib.h
#include <stdio.h>
int main()
{
char a[] = {"123"};
int x=0;
x= atoi(a); //char类型123转换int类型123
printf("%d",x); //此时x为123
}