#MystricalConcepts1 - Use of fflush() in C Language .
fflush();

#MystricalConcepts1 - Use of fflush() in C Language .

Have you ever used fflush() in c ?

If not yet , then you are at a perfect place to learn about it in a easy way.

Task - when you want to take two inputs one integer and one character

Problem Faced - During output after entering first input i.e. integer value, the output gets printed and you are not able to enter the second input i.e. character Value.

Like, Have you ever encounter such issue while coding in C.

As shown in Code Snippet given below:

Problem Faced - Taking two input values together. #MystricalConcept1


Reason - Whenever we store a value into a variable it first gets stored in a buffer called INPUT BUFFER before getting stored to the actual variable i.e. Memory Location, And as We have only a single INPUT BUFFER so as we press enter button after entering 1st value, the value of "enter key" gets stored in the INPUT BUFFER as 2nd Input value, so to get the second input i.e. Character Value, we need to first Clear the INPUT BUFFER.


Solution - To Solve this Problem fflush() came into picture.

fflush() - It is used to clear the buffer..

Syntax - fflush(stdlin);

Now Here, we will use fflush() after getting the first input i.e. integer value to clear the buffer, and then we can easily get the second input i.e. character value.

As shown in Code Snippet given below:

Use of fflush(); #MystricalConcept1


This technique, using fflush(), elegantly addresses input buffer challenges, ensuring a seamless user experience in C programming.

.

.

If you find value in this content, kindly consider sharing it with your Friends. Your support is greatly appreciated, and it helps foster a community of knowledge-sharing.

.

.

Follow me Anupravi Garg for more such content.

Thank you??




要查看或添加评论,请登录

Anupravi Garg的更多文章

  • SIH Visionary!!

    SIH Visionary!!

    Hey! LinkedIn Fam As #SIH is just round the corner so I am receiving a lot many doubts/Queries Regarding #SIH Like, ?…

    12 条评论

社区洞察

其他会员也浏览了