#include <stdio.h>
#include <string.h>
int main( void ){
int i;
char str1[8] = "hoge";
char str2[8];
char str3[8];
for( i = 0; i < strlen(str1); i++ ){
str2[i] = str1[i];
}
printf("[Not put null] str1 copied to str2: '%s' (length: %ld)\n", str2, strlen(str2));
for( i = 0; i < strlen(str1); i++ ){
str3[i] = str1[i];
}
if( strlen(str1) < sizeof(str3) ){
str3[strlen(str1)] = '\0';
}
printf("[Put null] str1 copied to str3: '%s' (length: %ld)\n", str3, strlen(str3));
char str4[8];
char str5[8];
strcpy(str4, str1);
strncpy(str5, str1, 3);
printf("[strcpy] str1 copied to str4: '%s' (length: %ld)\n", str4, strlen(str4));
printf("[strncpy] str1[:3] copied to str5: '%s' (length: %ld)\n", str5, strlen(str5));
char *str6 = "fuga";
char *str7;
str7 = str6;
printf("[Pointer] str6 copied to str7: '%s' (length: %ld)\n", str7, strlen(str7));
}