C語言練習題:指標(C language exercise: Pointer)
若您覺得文章寫得不錯,請點選文章上的廣告,來支持小編,謝謝。 If you like this post, please click the ads on the blog or buy me a coffee . Thank you very much. 指標的慣念可以看 C語言: 超好懂的指標,初學者請進 Pointer concepts: 1. Pointers in C Programming: What is Pointer, Types & Examples 2. Introduction to C Pointers 練習一:基本語法 設計一個C語言程式來呈現指標的語法,例如宣告、取址、取值等。 Exercise 1: Basic Syntax Design a C program to demonstrate the basic syntax of pointer. Such as declaration, address and value. 練習一參考解法: Exercise 1 solution: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 /* Pointer Basic Syntax Author: Holan */ #include <stdio.h> #include <stdlib.h> int main () { int n = 50 ; // declaration int * ip; // assignment ip = & n; printf( "The value of &n:%X \n " , & n); printf( "The value of n:%i \n " , n); printf( "The value of &ip:%X \n " , & ip); printf( "The value of ip:%X \n " , ip); ...