Read from console and Store Strings using a pointer to char and a char type array - C String

C examples for String:char array

Description

Read from console and Store Strings using a pointer to char and a char type array

Demo Code

#include <stdio.h>

int main()//from w  ww  .j av a 2s  .  c  om
{
     char name[8] ;
     char *pname;
    
     printf("\nEnter name: ");
     scanf(" %[^\n]", name);
     printf("Enter name again: ");
     scanf(" %[^\n]", pname);
    
     printf("name: %s\n", name);
     printf("pname: %s\n", pname);
    
     return(0);
}

Related Tutorials