Category: Pointer

21
May
2017

Typedef Enum Union Project

code: #include<stdio.h> typedef union { double weight; int size; char color[10]; } Description; typedef struct { int…

21
May
2017

Another Good Example of Struct using Function and Pointer

code: #include<stdio.h> typedef struct { int roll; char name[20]; double gp; double phy,chem,math; }sTudent; void inputStudent(sTudent *sp)…

21
May
2017

Using function with Struct user defined type also pointer

code: #include<stdio.h> typedef struct { int roll; char name[20]; double gp; } sTudent; void inputStudent(sTudent *sp) {…

20
May
2017

2d array dynamically with pointer/basics of 2d array

code: //dynamically 2d array #include<stdio.h> #include<stdlib.h> int **allocate(int nRows,int nCols) { int **p; p=(int**)malloc(nRows*sizeof(int*)); if(p==NULL) exit(0); int…

20
May
2017

Never Waste Your Memory, So use custom memory allocation with malloc() function and pointer to allocate memory dynamically, calloc(), realloc()

malloc() code: #include<stdio.h> #include<stdlib.h> int main() { int *p; int n; printf(“how many integers:”); scanf(“%d”,&n); p=(int*)malloc(n*sizeof(int)); if(p==NULL)…

20
May
2017

Void Pointer and Typecasting in Pointer

code: #include<stdio.h> int main() { void *vp; int x=100; vp=&x; //printf(“%d\n”,*vp); //it will give error because it’s…