Month: May 2017

21
May
2017

Use Pointer with Struct

code: #include<stdio.h> typedef struct{ int age; char name[20]; double gp; }student; int main() { student s1; student…

21
May
2017

Typedef Alias to Use Type without Struct keyword

code: #include<stdio.h> typedef int integer; //self declaration typedef struct Student student; struct Student{ int roll; char name[20];…

21
May
2017

Struct in C(User Defined Type)

code: #include<stdio.h> struct Student{ int roll; char name[20]; double gp; }; int main() { struct Student s1,s2,s3;…

21
May
2017

Array of String

theortecical concept source: http://stackoverflow.com/questions/20347170/char-array-and-char-array code: char *array = “One good thing about music”; char array[] = {“One”,…

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)…