Standard I/O, Format Specifiers & File Streams
“printf/scanf return values, format specifiers, and FILE* buffered file handling.”
1.Formatted I/O: Return Values & Format Traps
§ 5.1.Return Values of printf and scanf:
- printf("format", ...): Returns the total number of characters successfully printed.
Example: int n = printf("GATE"); prints GATE and sets n = 4.
- scanf("format", ...): Returns the number of input items successfully matched and assigned.
Example: scanf("%d %d", &a, &b) returns 2 on valid integers, or EOF (-1) on end-of-file.
File Streams in C:
- Files are represented by FILE* stream pointers.
- Functions: fopen("file.txt", "r"), fclose(fp), fgetc(fp), fputc(ch, fp), fread(), fwrite(), fseek(fp, offset, SEEK_SET/CUR/END), ftell(fp).
Primary Academic References & Exam Sources
Every concept in Notes From a B.Tech Brain is synthesized from authoritative academic texts, seminal peer-reviewed research, verified exam archives, and renowned university lectures.
Curated for clarity, rigorous numerical solving, and semester excellence:
Systematic beginner-to-advanced C with clear examples.
Clear step-by-step C explanations — great for semester lab preparation.