Like us on google+

Monday, 18 November 2013

Widgets

POWER OF scanf() IN C WHILE READING CHARACTER ARRAY.

#include<stdio.h>
int main()
{
    char name[30];
    printf("enter your full name\n");
    scanf("%[^\n]",name);
    printf("your full name is %s",name);

    return 0;
}
OUTPUT:
------------------------------------------
enter your full name
rajesh shreedhar bhat
your full name is rajesh shreedhar bhat
------------------------------------------ 
Brief explanation:
scanf("%[^\n]",name); in the above program reads the characters from the user until it encounters \n.....

If scanf("%s",name); was used in the above program then the output would be rajesh.

I hope this post was helpful .........

SHARE THIS POST   

  • Facebook
  • Twitter
  • Myspace
  • Google Buzz
  • Reddit
  • Stumnleupon
  • Delicious
  • Digg
  • Technorati
About us:
Hi guys Sandesh and Rajesh here ... studing engineering in PESIT started this blog as a google contest and also we love blogging ...Hope u like it ...Encourage us by liking us on g+... Any queries dont hesitate to ask Read More →

0 comments: