日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

typedef 字符串_typedef在C中使用字符数组(定义别名来声明字符串)的示例

發布時間:2023/12/1 编程问答 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 typedef 字符串_typedef在C中使用字符数组(定义别名来声明字符串)的示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

typedef 字符串

Here, we have to define an alias for a character array with a given number of maximum characters length to read strings?

在這里,我們必須為具有給定最大字符長度數的字符數組定義別名,以讀取字符串 ?

In the below-given program, we have defined two alias (typedefs) for character array and unsigned char:

在下面給出的程序中,我們為字符數組和無符號字符定義了兩個別名(typedef):

typedef char CHRArray[MAXLEN];typedef unsigned char BYTE;

MAXLEN is also defined with 50 by using define statement #define MAXLEN 50.

MAXLEN還與50通過定義語句的#define MAXLEN 50界定。

Declaring variables:

聲明變量:

CHRArray name;CHRArray city;BYTE age;

Explanation:

說明:

CHRArray name will be considered as char name[50], CHRArray city will be considered as char city[50] and BYTE age will be considered as unsigned char age.

CHRArray名稱將被視為char name [50] , CHRArray city將被視為char city [50] , BYTE age將被視為unsigned char age 。

Note: unsigned char is able to store the value between 0 to 255 (i.e. one BYTE value).

注意: unsigned char能夠存儲0到255之間的值(即一個BYTE值)。

Program:

程序:

#include <stdio.h> #include <string.h>#define MAXLEN 50typedef char CHRArray[MAXLEN]; typedef unsigned char BYTE;int main() {CHRArray name;CHRArray city;BYTE age;//assign valuesstrcpy(name, "Amit Shukla");strcpy(city, "Gwalior, MP, India");age = 21;//print valuesprintf("Name: %s\n", name);printf("city: %s\n", city);printf("Age : %u\n", age);return 0; }

Output

輸出量

Name: Amit Shukla city: Gwalior, MP, India Age : 21

翻譯自: https://www.includehelp.com/c-programs/typedef-example-with-character-array-define-an-alias-to-declare-strings.aspx

typedef 字符串

總結

以上是生活随笔為你收集整理的typedef 字符串_typedef在C中使用字符数组(定义别名来声明字符串)的示例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。