以下是一个编辑使用指针的基本程序,学习的过程中,void变量值不能赋给char, char的变量值与char*之间也不能互通,
char type cannnot exist in the function copystring.
so I must use *, and clearly delete the [],which is represent the array in this program use, except for the definiton.
#include<stdio.h>
#include<string.h>
void copyString(char dest, char src)
{
int i = 0;
while(src[i] != ‘\0’)
{
dest[i] = src[i];
i++;
}
dest[i] = 0;
}
int main()
{
int i=0;
char a[100],b[100];
scanf("%s %s",a,b);
copyString(a,b);
printf("%s\n",a);
return 0;
}
C语言指针的初步了解
最新推荐文章于 2024-08-02 21:25:25 发布