?? struct.c
字號:
#include <stdio.h>#include <string.h>#include <stdlib.h>typedef struct BIO{char name[16];unsigned age;}BIO;BIO *CreateBio(const char *name, unsigned age);int main(void){BIO exfriend;BIO *friend;friend = CreateBio("Sarah",16);if(friend != NULL)printf("My friend's name is %s\n""and my friend's age is %u\n",friend->name,friend->age);else puts("Failed to create Bio");if(friend != NULL){exfriend = *friend;printf("\nMy former friend's name is %s\n""and my former friend's age is %u\n",exfriend.name, exfriend.age);}free(friend);return 0;}BIO *CreateBio(const char *name, unsigned age){BIO *tmp = malloc(sizeof *tmp);if(tmp != NULL){unsigned i = sizeof(tmp->name);tmp->age = age;strncpy(tmp->name,name,i);tmp->name[i-1] = '\0';}return tmp;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -