Reading And Printing Strings - C String

C examples for String:String Console Input

Introduction

To read and print a character array use the %s conversion specifier.

Demo Code

#include <stdio.h> 

int main()//from ww w  .  j  a  va2 s. co  m
{ 
   char color[12] = {'\0'}; 
   printf("Enter your favorite color: "); 
   scanf("%s", color); 
   printf("\nYou entered: %s", color); 
}

Result


Related Tutorials