C/C++ Questions only (Stdio)
C++ programming on UNIX, C++ Networking,C++ Algorithm Questions and Answers
(Continued from previous question...)
C/C++ Questions only (Stdio)
1. What's wrong with the code "char c; while((c = getchar()) != EOF)
..."?
2. Why won't the code `` while(!feof(infp)) { fgets(buf, MAXLINE,
infp); fputs(buf, outfp); } '' work?
3. My program's prompts and intermediate output don't always show up
on the screen.
4. How can I read one character at a time, without waiting for the
RETURN key?
5. How can I print a '%' character with printf?
6. How can printf use %f for type double, if scanf requires %lf?
7. How can I implement a variable field width with printf?
8. How can I print numbers with commas separating the thousands?
9. Why doesn't the call scanf("%d", i) work?
10. Why doesn't the code "double d; scanf("%f",
&d);" work?
11. How can I specify a variable width in a scanf format string?
12. When I read numbers from the keyboard with scanf "%d\n", it
seems to hang until I type one extra line of input.
13. I'm reading a number with scanf %d and then a string with
gets(), but the compiler seems to be skipping the call to gets()!
14. I'm re-prompting the user if scanf fails, but sometimes it seems
to go into an infinite loop.
15. Why does everyone say not to use scanf? What should I use
instead?
16. How can I tell how much destination buffer space I'll need for
an arbitrary sprintf call? How can I avoid overflowing the destination
buffer with sprintf?
17. Why does everyone say not to use gets()?
18. Why does errno contain ENOTTY after a call to printf?
19. What's the difference between fgetpos/fsetpos and ftell/fseek?
20. Will fflush(stdin) flush unread characters from the standard
input stream?
21. I'm trying to update a file in place, by using fopen mode
"r+",
but it's not working.
22. How can I redirect stdin or stdout from within a program?
23. Once I've used freopen, how can I get the original stream back?
24. How can I read a binary data file properly?
(Continued on next question...)
Other Interview Questions
|