Reading and Writing String using scanf, gets and printf, puts || Lesson 67 || C Programming ||

Опубликовано: 05 Январь 2025
на канале: Learning Monkey
3,726
63

Reading and Writing String using scanf(), gets and printf(), putsIn this class, we will try to understand the Reading and Writing string using scanf(), gets and printf(), puts.In our previous class, we have covered how to declare and initialize a string.Table of Contents printf(), puts and scanf(), gets printf() and puts scanf(), getsprintf(), puts and scanf(), getsprintf() and putsWe will try to understand writing the string by using the programming example shown below.In c, we have two options: printf () and other by puts enclosed with the name of the ‘string’.The essential point that we have to understand in writing and reading a string is the use of %s conversion specifier.The %s conversion specifier is used to write or read a string.scanf(), getsThe image below is the program to understand the scanf() and gets to scan a string.The essential point to understand about scanf() is that it will scan only up to the first space in the string.In the above example, the scanf() function will scan only up to Learning, and the remaining string after the Learning is not read.Note: It is NOT at all suggestible to use scanf() for strings.The other alternative for scanf() is the gets functions.The gets function is used by giving the name of the string enclosed in the parentheses.Using the gets function, we can scan all the characters, including the spaces in the string.The scan of all the characters will end in gets if we press enter after entering the string.


#learningmonkey #cprogrammingforbeginners #placements #gatecse #cprogramming #cprogramminglanguage



Link for playlists:

   / @learningmonkey  


Link for our website: https://learningmonkey.in

Follow us on Facebook @   / learningmonkey  

Follow us on Instagram @   / learningmonkey1  

Follow us on Twitter @   / _learningmonkey  

Mail us @ [email protected]