How to use pointer to display a string in C

2 Answers

0 votes
#include <stdio.h>

int main(int argc, char **argv) 
{ 
    char arr[] = "This is pointers";
    char *p = arr;
 
    while(putchar(*p++));
        
    return 0;
}

/*
run:

This is pointers

*/

 



answered Jun 30, 2015 by avibootz
0 votes
#include <stdio.h>
   
int main(int argc, char **argv) 
{ 
    char s[20] = "c programming";
    char *p = s;

    while(putchar(*p++)) ;
    
    return 0;
}
   
/*
  
run:
   
c programming

*/

 



answered Sep 28, 2015 by avibootz
...