Write a scanf function in c which accept sentence from user




Write a scanf function in c programming language which accept sentence from user


#include<stdio.h>
#define MAX 500

int main(){

    char arr[MAX];

    printf("Enter any sentence which can include spaces.\n");
    printf("To exit press enter key.\n");
    scanf("%[^\n]s",arr);

    printf("You had entered: \n");
    printf("%s",arr);

    return 0;
}

Sample output:

Enter any sentence which can include spaces.
To exit press enter key.
May I help you?
You had entered:
May I help you?





1. Write a c program to convert decimal number to hexadecimal number.
3. Write a c program to convert octal number to decimal number.
4. Write a c program to convert octal number to hexadecimal number.
5. Write a c program to convert hexadecimal number to decimal number.
6. Write a c program to convert hexadecimal number to octal number.
8. Write a c program to convert binary number to hexadecimal number.
9. Write a c program to convert binary number to octal number.
11. Write a c program to convert hexadecimal number to binary number.
12. Write a c program to convert octal number to binary number.
14. Write a c program to convert centigrade to fahrenheit.

15 comments:

Anonymous said...

thank you so much. lol

Banibrata Mandal said...

pleas explain it..
scanf("%[^\n]s",arr);

Vigneshrajan said...

/n denotes new line. once you pressed enter key the scanf statment ends

GloriaPoppyharlow said...

I hope there are still people here, but can I loop the array so that the program ask for multiple strings? and have it all displayed at the end? Thanks

Sivanandhana Girish said...

Had a great time reading your blog. Thanks for sharing this post to our vision.
Spoken English Classes in Chennai
Best Spoken English Classes in Chennai
IELTS Coaching in Chennai
IELTS Coaching Centre in Chennai
English Speaking Classes in Mumbai
English Speaking Course in Mumbai
IELTS Classes in Mumbai
IELTS Coaching in Mumbai
IELTS Coaching in Anna Nagar
Spoken English Class in Anna Nagar

arolincy said...

Thanks for the informative article. This is one of the best resources I have found in quite some time.
TOEFL Coaching in Chennai
TOEFL Course in Chennai
Informatica MDM Training in Chennai
IELTS Training in Chennai
Japanese Language Course in Chennai
Spoken English in Chennai
TOEFL Coaching in VelaChery
TOEFL Coaching in Tambaram

The India said...

Delhi Agra Jaipur Tour by Bus
Delhi to Jaipur Same Day Tour
Delhi One Day Tour Package
Delhi Sightseeing One Day
Delhi Sightseeing Tour by Bus
Delhi Jaipur One Day Tour Package
Haridwar, Rishikesh Tours by Volvo

Anonymous said...

Just copied the WHOLE code, it made an exception: Exception thrown at 0x00007FFCEFC0F3A9 (ucrtbased.dll) in Project6.exe: 0xC0000005: Access violation writing location 0x0000006B2C7A0000.

balamurugan said...

I really liked and I got some innovative ideas for improving my thoughts from well defined content.
IELTS Coaching in Chennai
IELTS Coaching centre in Chennai
French Classes in Chennai
pearson vue test center in chennai
Informatica Training in Chennai
Data Analytics Courses in Chennai
spanish classes in chennai
content writing course in chennai
IELTS Coaching in OMR
IELTS Coaching in Porur

The India said...

Popular Fashion Blogs in Surat
Fashion Blogger in Surat
Surat Blogger
Indian Fashion Blogger

Vijayakash said...


Excellent blog with lots of information. I have to thank for this. Do share more.

German Classes In Bangalore

Adhuntt said...

Great blog thanks for sharing Instagram and Facebook have provided an amazing place for new brands to grow and flourish. We can find the perfect niche for your brand on the best social media platforms. Marketing through social media brings forth global audience without all these physical boundaries. Analyze and take over the competition with ease with Adhuntt Media’s digital marketing tools and strategies.
web designing company in chennai

Karuna said...

Nice blog thanks for sharing Say no to unethical ways for growing plants fast. We at Karuna Nursery Gardens stick to traditional and environment friendly methods of caring and growing therefore enabling us to showcase the largest collection on organic plants in Chennai.
rental plants in chennai

Pixies said...

Excellent blog thanks for sharing It’s very important to have the best beauty parlour equipment to run a successful salon. Pixies Beauty Shop is the best place in Chennai to get high quality imported top brands at the best price.
Cosmetics Shop in Chennai

simran said...

Thanks for information.i really like your blog and information keep it up and i m also waiting for your next blog ...... Rajasthan honeymoon packages Rajasthan tour packages