使用C語言中的typedef關鍵字來解釋結構體
Aug 25, 2023 pm 01:25 PM
c語言
解釋
typedef
Typedef
‘C’允許使用‘typedef’關鍵字定義新的資料類型名稱。使用‘typedef’,我們不能建立新的資料類型,而是為已經存在的類型定義一個新的名稱。
Syntax
typedef datatype newname;
登入後複製
Example
的中文翻譯為:範例
typedef int bhanu; int a; bhanu a; %d
登入後複製
- This statement tells the compiler to recognize 'bhanu' as another name for 'int'.
- 'bhanu' is used to create another variable 'a' .
- 'bhanu a 'declares 'a' as a variable of type 'int'.
Example
的中文翻譯為:範例
#include <stdio.h> main (){ typedef int hours; hours h; //int h; clrscr (); printf("Enter hours”); scanf ("%d”, &h); printf("Minutes =%d”, h*60); printf("Seconds = %d”, h*60*60); getch (); }
登入後複製
輸出
Enter hours =1 Minutes = 60 Seconds = 360
登入後複製
typedefining一個結構的範例
#typedef struct employee{ int eno; char ename[30]; float sal; } emp; main (){ emp e = {10, "ramu”, 5000}; clrscr(); printf("number = %d”, e.eno); printf("name = %d”, e.ename); printf("salary = %d”, e.sal); getch (); }
登入後複製
輸出
Number=10 Name=ramu Salary=5000
登入後複製
以上是使用C語言中的typedef關鍵字來解釋結構體的詳細內容。更多資訊請關注PHP中文網其他相關文章!
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱門文章
擊敗分裂小說需要多長時間?
3 週前
By DDD
倉庫:如何復興隊友
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
1 週前
By 尊渡假赌尊渡假赌尊渡假赌
公眾號網頁更新緩存難題:如何避免版本更新後舊緩存影響用戶體驗?
3 週前
By 王林

熱門文章
擊敗分裂小說需要多長時間?
3 週前
By DDD
倉庫:如何復興隊友
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
1 週前
By 尊渡假赌尊渡假赌尊渡假赌
公眾號網頁更新緩存難題:如何避免版本更新後舊緩存影響用戶體驗?
3 週前
By 王林

熱門文章標籤

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)