Basic Program of Pointer

understanding c pointers

Basic Program of Pointer #include <stdio.h> int main() { printf(“\n\n\t\tEduguru – Pointer program\n\n\n”); int var = 24; // actual variable declaration int *p; p = &var; // storing address of int variable var in pointer p printf(“\n\nAddress of var variable is: %x \n\n”, &var); // address stored in pointer variable printf(“\n\nAddress stored in pointer variable … Read more

C Program to Count Vowels and Consonants in a String using Pointer

  #include <stdio.h> int main() { char str[100]; char *p; int vCount=0,cCount=0; printf(“Enter any string: “); fgets(str, 100, stdin); //assign base address of char array to pointer p=str; //’\0′ signifies end of the string while(*p!=’\0′) { if(*p==’A’ ||*p==’E’ ||*p==’I’ ||*p==’O’ ||*p==’U’ ||*p==’a’ ||*p==’e’ ||*p==’i’ ||*p==’o’ ||*p==’u’) vCount++; else cCount++; //increase the pointer, to point next … Read more

C Program to Print String using Pointer

#include <stdio.h> int main() { char str[100]; char *p; printf(“Enter any string: “); fgets(str, 100, stdin); /* Assigning the base address str[0] to pointer * p. p = str is same as p = str[0] */ p=str; printf(“The input string is: “); //’\0′ signifies end of the string while(*p!=’\0′) printf(“%c”,*p++); return 0; }