c語言指針訪問 靜態變量_使用C中的指針訪問變量的值

c語言指針訪問 靜態變量

As we know that a pointer is a special type of variable that is used to store the memory address of another variable. A normal variable contains the value of any type like int, char, float etc, while a pointer variable contains the memory address of another variable.

眾所周知,指針是一種特殊類型的變量,用于存儲另一個變量的內存地址。 普通變量包含int , char , float等任何類型的值,而指針變量包含另一個變量的內存地址。

Here, we are going to learn how can we access the value of another variable using the pointer variable?

在這里,我們將學習如何使用指針變量訪問另一個變量的值

Steps:

腳步:

  1. Declare a normal variable, assign the value

    聲明一個普通變量,賦值

  2. Declare a pointer variable with the same type as the normal variable

    聲明與普通變量相同類型的指針變量

  3. Initialize the pointer variable with the address of normal variable

    用普通變量的地址初始化指針變量

  4. Access the value of the variable by using asterisk (*) - it is known as dereference operator

    通過使用星號( * )訪問變量的值-這稱為解引用運算符

Example:

例:

Here, we have declared a normal integer variable num and pointer variable ptr, ptr is being initialized with the address of num and finally getting the value of num using pointer variable ptr.

在這里,我們已經聲明了一個普通的整數變量num和指針變量PTR,PTR正在與NUM的地址,并終于得到使用指針變量PTR num的值初始化。

#include <stdio.h>
int main(void)
{	
//normal variable
int num = 100;	
//pointer variable
int *ptr;		
//pointer initialization
ptr = &num;		
//pritning the value 
printf("value of num = %d\n", *ptr);
return 0;
}

Output

輸出量

value of num = 100

翻譯自: https://www.includehelp.com/c/accessing-the-value-of-a-variable-using-pointer-in-c.aspx

c語言指針訪問 靜態變量

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/542329.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/542329.shtml
英文地址,請注明出處:http://en.pswp.cn/news/542329.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

迭代器 java_Java設計模式8:迭代器模式

迭代器模式迭代器模式又叫做游標(Cursor)模式&#xff0c;其作用是提供一種方法訪問一個容器元素中的各個對象&#xff0c;而又不暴露該對象的內部細節。迭代器模式結構迭代器模式由以下角色組成&#xff1a;1、迭代器角色負責定義訪問和遍歷元素的接口2、具體迭代器角色實現迭…

html二級下拉菜單模板,基于jQuery實現二級下拉菜單效果

本文通過代碼實例詳細介紹一下簡單的二級下拉菜單是如何實現的&#xff0c;當然還有更為復雜的二級菜單&#xff0c;不過先學會如何制作簡單的&#xff0c;分享給大家供大家參考&#xff0c;具體內容如下代碼如下&#xff1a;下拉菜單nav a{text-decoration:none;}nav>ul>…

給定一個整數判斷是否為素數_Ruby程序檢查給定數字是否為素數

給定一個整數判斷是否為素數檢查素數 (Checking prime number) Before getting into writing the code, let us understand what exactly the prime numbers are? So that we could easily design its logic and implement it in the code. Prime numbers are those numbers w…

python 正則findall右斜杠_python中正則表達式的使用

本文將介紹幾個最常用的正則符號&#xff0c;以及正則表達式的應用場景。如果說【數學表達式】刻畫的是數字的內在規律&#xff0c;那么【正則表達式】則是用來刻畫和描述字符串內在規律的表達式。記得剛接觸python時學習過slice&#xff0c;replace&#xff0c;split等方法&am…

JavaScript | 用戶定義函數的一些示例

1) Design a function, print message and assign the function to a variable and print it like a function 1)設計一個功能&#xff0c;打印消息并將該功能分配給變量&#xff0c;然后像打印功能一樣打印 <html lang"en"><head><script>functi…

網易 html5,別再想不開做H5了

寫這篇文章的時候網易噠噠《飼養手冊》H5刷屏了&#xff0c;但我們依舊不建議品牌做H5。H5作為大眾傳播工具的時代&#xff0c;已經過去了。盡管去年有很多H5曾經刷屏過&#xff0c;但在當時我們就一直跟朋友說&#xff0c;不要再嘗試H5了&#xff0c;性價比根本算不過來&#…

python打開word后再關閉再打開出錯_用Python寫了個程序調用word,運行完后再手動打開word文檔就變慢了,這是為啥?...

公司歸檔文件比較麻煩&#xff0c;于是用Python寫了個程序自動歸檔&#xff0c;運行無錯誤。但是運行完后問題就來了&#xff0c;自己手動打開word文檔時速度變得奇慢&#xff0c;打開一個文檔需要1~2min,請各位同仁幫我看看。下為源代碼#歸檔.pyimport osimport refrom win32c…

編程 mcq_MCQ | 8255 PPI(可編程外圍接口)

編程 mcqQuestion 1: How many pins does the 8255 PPI IC contains? 問題1&#xff1a;8255 PPI IC包含多少個引腳&#xff1f; 24 24 20 20 32 32 40 40 Answer: d. 40 答案&#xff1a;d。 40 Question 2: In which mode do all the Ports of the 8255 PPI work as Input…

flex 修改生成html,CSS Flex –動畫教程

如果一張圖片勝過千言萬語 —— 那么動畫呢&#xff1f; Flex 無法通過文字或靜態圖像有效地完全解釋。為了鞏固你對flex的了解&#xff0c;我制作了這些動畫演示。注意 overflow: hidden 行為類型是默認值&#xff0c;因為 flex-wrap 還未設置。為了獲得更好的想法&#xff0c…

c#c#繼承窗體_C#繼承能力問題和解答 套裝5

c#c#繼承窗體1) Which keyword is used to call a superclass constructor from child class? supertopconstbase Answer & Explanation Correct answer: 4base In C#.NET, base keyword is used to call a base class constructor from a derived class. 1)使用哪個關鍵字…

python php 網站_python php網站

{"moduleinfo":{"card_count":[{"count_phone":1,"count":1}],"search_count":[{"count_phone":4,"count":4}]},"card":[{"des":"阿里技術人對外發布原創技術內容的最大平臺&…

陜西2021高考成績在哪查詢,2021陜西高考成績查詢入口

2021陜西高考成績查詢入口2021-05-13 19:38:37文/張敏有很多同學在關注2021年陜西高考成績的查詢方式&#xff0c;為了方便考生們查詢成績&#xff0c;小編整理了陜西高考成績查詢入口&#xff0c;希望對同學們有幫助。2021陜西高考成績查詢通道高考成績查詢過后應該做什么1、了…

Can’t Activate Reporting Services Service in SharePoint

訪問sharepoint的reporing service 的報表的時候莫名其妙的報錯&#xff1a; The requested service, http://amatltapp02:32843/1dacf49a2f7a4a6daa8db5768539893f/ReportingWebService.svc could not be activated. See the servers diagnostic trace logs for more informat…

scala python_Scala與Python | 哪種編程語言更好

scala pythonScala is a general-purpose programming language developed by Martin Odersky in 2004. Scala是Martin Odersky在2004年開發的通用編程語言。 Both Scala and Python are general purpose programming that is used in Data Science that supports Object Orie…

查找文件中每行第二個單詞_日語單詞中的長短音區別在哪里,日語長短音發音有什么規律...

日語單詞記憶長短音規律一、如果單詞的漢字在中文漢語拼音中是前鼻音&#xff0c;在日語讀音中就會帶撥音「ん」&#xff1b; 如果單詞的漢字在中文漢語拼音中是后鼻音&#xff0c;在日語讀音中就會帶有長音。例&#xff1a;専門&#xff08;zhuan men&#xff09;&#xff0d;…

SQL Server 執行計劃利用統計信息對數據行的預估原理二(為什么復合索引列順序會影響到執行計劃對數據行的預估)...

本文出處&#xff1a;http://www.cnblogs.com/wy123/p/6008477.html 關于統計信息對數據行數做預估&#xff0c;之前寫過對非相關列&#xff08;單獨或者單獨的索引列&#xff09;進行預估時候的算法&#xff0c;參考這里。  今天來寫一下統計信息對于復合索引在預估時候的計…

計算機三四級網絡技術,全國計算機等級考試四級網絡技術論述題真題3

1.(2003年)網絡安全策略設計的重要內容之一是&#xff1a;確定當網絡安全受到威脅時應采取的應急措施。當我們發現網絡受到非法侵入與攻擊時&#xff0c;所能采取的行動方案基本上有兩種&#xff1a;保護方式與跟蹤方式。請根據你對網絡安全方面知識的了解&#xff0c;討論以下…

哈密頓路徑_檢查圖形是否為哈密頓量(哈密頓路徑)

哈密頓路徑Problem Statement: 問題陳述&#xff1a; Given a graph G. you have to find out that that graph is Hamiltonian or not. 給定圖G。 您必須找出該圖是否為哈密頓量 。 Example: 例&#xff1a; Input: 輸入&#xff1a; Output: 1 輸出1 Because here is a …

京東自動下單軟件_黃牛軟件自動下單秒殺商品 警方用科技手段打擊

法制日報全媒體記者 張維定了10個鬧鐘,也搶不到一瓶茅臺&#xff1b;等了很久的iPhone新手機,打開網頁就秒沒……或許并不是因為你的手速、網速慢,而是黃牛黨在用軟件和你搶商品。近日,在“凈網2019”專項行動中,阿里安全協助江蘇省南通市公安局成功打掉了一個制作銷售黃牛軟件…

Mysql基礎之DML語句

增 1 給表的所有字段插入數據 INSERT INTO 表名 VALUES(值1&#xff0c;值2&#xff0c;值3&#xff0c;...&#xff0c;值n)&#xff1b; 2 給表的指定字段插入數據 INSERT INTO 表名(屬性1&#xff0c;屬性2&#xff0c;...&#xff0c;屬性n) VALUES(值1&#xff0c;值2&a…