C - How to Use INTP as Integer Pointer using TypeDef in C Language.


IncludeHelp 12 August 2016

In this code snippet we will learn how to declare a typdef for integer pointer (int*)? if we don't want to use integer pointer (int*) every time in our program we want to customize it with a simple name. By using typedef we can make it simple like INTP (for integer pointer).

In this example we will declare INTP as Integer Pointer (int*) using typedef in c.

C Code Snippet - Integer Pointer as INTP using TypeDef in C

/*C – How to Use INTP as Integer Pointer using TypeDef 
in C Language.*/

#include <stdio.h>

//define typedef for integer pointer

typedef int* INTP;

int main(){
	//use INTP as integer pointer
	int normalVar;
	INTP number=&normalVar;
	
	printf("Enter an integer number: ");
	scanf("%d",number);
	
	printf("number (using pointer) is: %d\n",*number);
	printf("number (using normalVar) is: %d\n",normalVar);
	
	return 0;
}

    Enter an integer number: 362436
    number (using pointer) is: 362436
    number (using normalVar) is: 362436



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.