Write a scanf function in c which accept paragraph from user




Write a scanf function in c programming language which accept paragraph from users


#include<stdio.h>
#define MAX 500

int main(){

    char arr[MAX];

    printf("Enter any paragraph which can include spaces or new line.\n");
    printf("To exit press the tab key.\n");
    scanf("%[^\t]s",arr);

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

    return 0;
}

Sample output:

Enter any paragraph which can include spaces or new line.
To exit, press the tab key.
C is powerful language.
I am learning c from
cquestionbank.blogspot.com

You had entered:
C is powerful language.
I am learning c from
cquestionbank.blogspot.com





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.

5 comments:

mani said...

scanf("%[^\t]s",arr);
please any one explain this

Priyanka kumari said...

scanf("%[^\t]s",arr);
It means scanf will accept characters until it doesn't get '\t' i.e. tab character .

scanf("%[^\n]s",arr);
It means scanf will accept characters until it doesn't get '\n' i.e. new character .

Anonymous said...

thanks

urvinder said...

hello sir,,,,,may i get a help for the strstr function of c with explanation of it

Anonymous said...

plz anyone explain the mechanism of this