a tons of thanks to you sir..the way you clear the concepts is just awesome & most cool thing is that..u are doing it in hindi..loved all of them..thanks a lot sir...
The error is due to the first scanf. Scanf() takes in the characters/values from the buffer but leaves the ' ' in the input buffer. Then gets() reads the input buffer and there exist ' ' in the buffer. But ' ' is delimiter for gets(). So in the end, gets() doesn't put anything into the variable. Now, the buffer is empty. Whatever we type is read by the next scanf() function. For that, we have to know the behavior of every input function. The best thing to do is put this code after every scanf(). while(getchar()!=' '); getchar() will also read from input buffer one by one. When getchar() reads ' ' . The while loop closes. That leads to buffer being empty.
Sir when we do in general scanf then at that why this problem not created..that buffer is not created.... Like Scanf("%d",&a); Scanf("%d",&b); In this also /n will be left in the buffer....
we do not require a buffer here as we have no intention of saving the input value to the hard disk, and therefore, the input value is not saved due to which, when you run the program again, the user is always asked to enter a new value. Therefore, you only require a buffer at a place where you need to store the entered value.
hi sir,sir can i get the the program of reading a raw file image and save it as bmp format file?...so if possible pls give me the program .....wishing the answer from u sir.....
Because gets () function iself place the cursor to next line . But in case of scanf we have to press the enter key after the entered data ,to move the cursor into the next fresh line.
Sir when we do in general scanf then why this problem not created..that buffer is not created.... Like Scanf("%d",&a); Scanf("%d",&b); In this also /n will be left in the buffer....
Nice video AAP jaisa padate ho usse mera confidence level phle se jyada increase ho jata h thank you sir
🤣🤣🤪🤪
Your explaination is very understandable.
Your determination to spread ur knowledge is awesome sir 👏👏u will always be a great guru sir ☺️😊☺️
a tons of thanks to you sir..the way you clear the concepts is just awesome & most cool thing is that..u are doing it in hindi..loved all of them..thanks a lot sir...
Sir really u have explained very simple way which we can understand.
Thank u sir..
Sir you are best teacher in the world
Nice explanation sir you are great teacher I find any language simple now👌👍👌👍👍
Nice explanation sir hatsoff
Excellent Lecture.
Thank you sir 🙏🙏
Genius sir great we need more
very useful for all students..
Sir ur videos are awesome
thanks sir,for explaining fflush() function.
for your explanation 👏👏👏👏
Thank you so much sir, you described very well.
Great explanation ❤️
Thankyou sir ji 🙏
The error is due to the first scanf. Scanf() takes in the characters/values from the buffer but leaves the '
' in the input buffer. Then gets() reads the input buffer and there exist '
' in the buffer. But '
' is delimiter for gets(). So in the end, gets() doesn't put anything into the variable. Now, the buffer is empty. Whatever we type is read by the next scanf() function.
For that, we have to know the behavior of every input function.
The best thing to do is put this code after every scanf().
while(getchar()!='
');
getchar() will also read from input buffer one by one. When getchar() reads '
' . The while loop closes. That leads to buffer being empty.
sir what is the difference between fputs and fwrite? can we write integer by using fputs function or this function is only to write characters?
😘😘
Sir when we do in general scanf then at that why this problem not created..that buffer is not created....
Like
Scanf("%d",&a);
Scanf("%d",&b);
In this also /n will be left in the buffer....
Same doubt:(
we do not require a buffer here as we have no intention of saving the input value to the hard disk,
and therefore, the input value is not saved due to which, when you run the program again, the user is always asked to enter a new value.
Therefore, you only require a buffer at a place where you need to store the entered value.
I think sir in the code block is supported windows base c so int variables take 4 bytes also total 9 bytes
Tysm sir😊
sir fwrite ka use kr kr kya hum dot txt extantion use kr skhte h dot dat ke replace mein?
❤️❤️❤️❤️
❤️❤️❤️
I have a question Sir ,that at 17:15 how can float type (book price) store a string (book title) ?
Same doubt...
Did you get your answer?
Write back,please.
It will store ASCII value of 1st character i.e D
sir, please upload a video on how to check file is empty or not? i searched google but not understand the methods of doing this,
Sir agar ek se jyada record ho to kya hamein dono variable ka address btana pdega
Sir record1 ka kya mtlb hai
3rd argument ka kya mtlb hai??
can we use fflush() after every scanf ??? will it create a problem ????
hi sir,sir can i get the the program of reading a raw file image and save it as bmp format file?...so if possible pls give me the program .....wishing the answer from u sir.....
Sir gets() k bad ek or fflush() q ni dale ?
bhai ek hi zarurat hoti hai
Because gets () function iself place the cursor to next line .
But in case of scanf we have to press the enter key after the entered data ,to move the cursor into the next fresh line.
Sir 3rd argument ka kya meaning thi
sir agar isko binary mode me open nhi krke normal way me open krte to??
sir I declare a string as char s[4] but i can 5 character as input using gets().......
how is it possible??
Sir kya hum file name ki jagah variable ka naam de skte hai jis variable me humne user se input krwaya hai.???
Sir .txt file tho suna tha lekin .dat file kiya hote hai??
google nhi h kya
sir what is use of stdin and stdout
Hello Sir . Apny .dat file q bnay . iska kya purpose h ??
Sir 100 ke bad
kyu buffer me tha?
sir fflush() mention karne ke baad bhi buffer empty nahi ho raha hai
+Saurabh Shukla #include
struct book
{
int bookid;
char title[20];
float price;
};
int main()
{
FILE *fp;
fp=fopen("f11.dat","wb");
struct book b1;
printf("Enter Bookid, Title and Price of Books: ");
scanf("%d",b1.bookid);
fflush(stdin);
gets(b1.title);
scanf("%f",&b1.price);
fwrite(&b1,sizeof(b1),1,fp);
fclose(fp);
+Saurabh Shukla thanks sir
@@learner_jpr bro scanf("%d",b1.bookid); me '&' missing hai
Even usingFFlush(stdin) the price didn't appear on output
i am using visual studio for this....
When I entered the same code price didn't appear
use fflush after gets(b1.title);
fflush( ) use karne ke baad bhi data enter nehi ho paraha he
Where shoul i make this prgrm
codeblocks
gets() does not work on text editor of ubuntu. so to remove this problem what should i do?
Fgets will wrk..use it instead..
So late but it does work it just gives the warning.
Sir Mene same program write Kiya lakin Mene jab complier pr display Kiya to price ki value -NAN show ho rhi h
Anybody plzz tell me
wah kya likes hai 222 lul
❤️❤️❤️
Sir when we do in general scanf then why this problem not created..that buffer is not created....
Like
Scanf("%d",&a);
Scanf("%d",&b);
In this also /n will be left in the buffer....