C Program to Print String using Pointer

Program to print string using pointer in c; Through this tutorial, we will learn how to write and print string using pointer in c.

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: ");
    //'
#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;
}
' signifies end of the string while(*p!='
#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;
}
') printf("%c",*p++); return 0; }

The output of the above c program; is as follows:

Enter any string: my string
The input string is: my string

Recommended C Programs

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *