勉強した部分は関数の呼び出し、アドレス、ポインタ、構造体のあたりです。
#include <stdio.h>
void strcopy(char *sp2, char *sp1);
int main(void)
{
char str1[100],str2[100];
printf("文字列を入力->");
scanf("%s",str1);
strcopy(str2,str1);
printf("str1[] = %s\n",str1);
printf("str2[] = %s\n",str2);
return 0;
}
void strcopy(char *sp2, char *sp1)
{
#include <stdio.h>
void strcopy(char *sp2, char *sp1);
int main(void)
{
char str1[100],str2[100];
printf("文字列を入力->");
scanf("%s",str1);
strcopy(str2,str1);
printf("str1[] = %s\n",str1);
printf("str2[] = %s\n",str2);
return 0;
}
void strcopy(char *sp2, char *sp1)
{
for( ;*sp1 = '\0'; sp1++, sp2++)
{
*sp2 = *sp1;
}
*sp2 = '\0';
}