Use of char pointer in C

 Use of char pointer


if you want to understand the code, you need to think and imagine every line of code and behave like compiler.

Q:1

#include<stdio.h>

int main()

{

    char *ch;//declaring character pointer

    ch="compuhelp"; //assigning string to pointer 

    printf("\n String is %s",ch);

}//end of main


Q2:Assigning string array to character pointer.

#include<stdio.h>
int main()
{
    char *ch;
    char str[15];
    printf("Enter string :");
    scanf("%s",str);
    ch=str;
    printf("\n String is %s",ch);
    printf("\n Value of str is %s",str);
}//end of main

Comments