输出字符乱码问题
出现图片里的乱码 编译通过没错误 name : 应该显示 Lee 不过出现乱码 找不出原因
#include <stdio.h>
struct Human
{
char name[20];
int age;
int gender;
};
enum {MALE, FEMALE};
struct Human Create_Human(char *name, int age, int gender);
int Print_Human(struct Human *human);
char copy_str(char *str1,char *str2);
int main()
{
struct Human Lee = Create_Human("Lee", 40, MALE);
Print_Human(&Lee);
return 0;
}
struct Human Create_Human(char *name, int age, int gender)
{
struct Human human;
human.age = age;
human.gender = gender;
copy_str(human.name, name);
return human;
}
int Print_Human(struct Human *human)
{
printf("Name : %s \n", human->name);
printf("Age : %d \n", human->age);
if(human->gender == MALE)
{
printf("Gender : Male \n");
}
else if (human->gender == FEMALE)
{
printf("Gender : Female \n");
}
return 0;
}
char copy_str(char *str1,char *str2)
{
while(*str2)
{
str2++;
str1++;
}
*str1='\0';
return 1;
}
[此贴子已经被作者于2016-3-9 20:38编辑过]