Untitled
unknown
plain_text
4 years ago
561 B
7
Indexable
/*C program to print a string using pointer*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    char str[20];
    char *pStr;
    int i;
    printf("Type a string: ");
    scanf("%s",str);
    gets(str);
    pStr=str;  //assigning pointer to string
    int length=0;       //getting length of the string
    for(i=0;str[i]!='\0';i++){
        length++;
    }
    int j;      //using pointer to print string in reverse
    for(j=0;j<length;j++){
        int num=length-j;
        printf("\n%p",*(pStr+num));
    }
    return 0;
}Editor is loading...