Category: Language

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

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…

20
May
2017

Pointer Basic Clear to Clearer with Increment

code: #include<stdio.h> int main() { int x[]={10,20,30}; int *p; p=&x; int k; k=*p; printf(“%d\n”,k); k=++(*p); printf(“%d\n”,k); k=*p++;…

19
May
2017

Char Pointer Practical Example Using String Input and String/Char Variable Passing

code: #include<stdio.h> void toggleChar(char *sptr){ int i; for(i=0;*(sptr+i)!=’\0′;i++) { if(*(sptr+i)>=’a’ && *(sptr+i)<=’z’) *(sptr+i)=*(sptr+i)-32; else if(*(sptr+i)>=’A’&& sptr[i]<=’Z’) *(sptr+i)=*(sptr+i)+32;…