 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you the difference between scanf and gattus functions which are available in C programming. Both the functions are required to read string from user. Before starting, you can note my information, you can follow or subscribe my youtube channel through the url youtube.com slash sanjaygupta underscore tech school. You can download my programming app TechMaze which is available on google play. Now I am going to demonstrate you the difference between scanf and gattus. So first I am including a header file that is stdi.h. Then I am defining main function. Inside main, I am declaring a character array str. Now with the help of printf, I am going to display the message enter string. So first time using scanf function with %s to read values of string. So here you can see scanf is written which is using format specify %s and str is string. So the scanf function using %s can read string excluding spaces. So if you want to enter space and you are using scanf with %s then this cannot read spaces. So you can say scanf can read multiple characters entered by the user and reading will be terminated when you will be pressing space or enter key. So if you want to enter any string excluding spaces then only it can be received through scanf using %s otherwise not. So I am printing the contained again back on console with the help of %s and printf statement. So here you can see I have received input from a user using scanf and %s and I have printed the entered string back on console using printf %s. So first I am executing this code and I am entering sanje only and I am pressing enter key. So you can see it is reading the content properly. Now again I am executing this code and this time I am entering a space b and then I am pressing enter key. So you can see the output you have entered only a so reading is terminated while I have entered space bar. So scanf using %c cannot read string including spaces. So as soon as you press space bar reading gets terminated automatically. So this is the use of scanf to read any string from user. So if you want to read string without any space then you can prefer scanf. But if you want to read string including spaces then you can use getters. So now I am removing this statement or I am making it comment and I am using another statement that is getters and I am writing str inside it. So this statement reads string including spaces. So now we have two different functions. First one is scanf %s which reads string excluding spaces and getters reads strings including spaces. So now again I am executing this code. Notice that scanf is coming now. It won't execute only getters will be executed. So I am executing this code. Again I am entering a space b and enter. This time you can see a space and b. All three characters are entered properly. So here you have to understand that space is also a character. So it will occupy one byte of string and space is treated as spatial symbol. So this way you can understand the difference that if you want to read any particular string including space then we can prefer getters instead of scanf. Now if you want to read any name so I am modifying the size of string as 20. Now I will be typing my name. Sanjay space Gupta. So you can see whole name is entered properly and it is including spaces also. So this is possible with the help of getters. If I use scanf %s then only Sanjay will be received from the console. Space and Gupta will be terminated automatically. So I hope you have understood the difference between getters and scanf. So always use scanf when you want to read string excluding spaces and you can use getters if you want to read spaces while entering strings. So if you want to watch more programming related videos you can follow or subscribe my youtube channel through the url youtube.com slash sanjaygupta underscore tech school. You can download my programming app TechMS which is available on google play. Thank you for watching this video.