Logic:
scanfjab%sformat specifier use karta hai, toh woh input tab tak read karta hai jab tak use koi Whitespace (Space, Tab, ya Newline) nahi milta.Execution: Input hai
"CS 2023".scanfne "CS" read kiya.Jaise hi usne Space dekha, usne read karna band kar diya.
Output: Isliye
Pka output sirf CS hoga.
2. Code Q: gets ka behavior
C
gets(s);Logic:
gets()function puri line read karta hai jab tak use Newline (Enter key) nahi milta. Yeh Spaces ko bhi input ka part maanta hai.Execution: Input hai
"CS 2023".getsne pura text padha kyunki beech mein space allow hota hai.
Output: Isliye
Qka output CS 2023 hoga.
| Feature | scanf("%s", s) | gets(s) |
| Space Handling | Space aate hi ruk jata hai (stops at space). | Space ko bhi read karta hai. |
| Stop Condition | Whitespace (Space/Tab/Newline) | Newline (Enter key only) |
| "CS 2023" Input Output | CS | CS 2023 |