PROGRAMMING IN C/Student Engineering Notebook
Page 10·notes
PREPROCESSOR DIRECTIVES, MACROS & FILE I/O—~28 MIN READ

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

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).

SOURCE TRANSPARENCY & CITATIONS

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 University Lecture Series
The C Programming Language (2nd Edition) ·
LECTURE SERIES
RECOMMENDED YOUTUBE EDUCATORS & FULL-COURSE PLAYLISTS

Curated for clarity, rigorous numerical solving, and semester excellence:

Neso Academy · C Programming Full Course↗Instructor: Neso Academy · Covers: Data types, pointers, arrays, functions, recursion, file I/O

Systematic beginner-to-advanced C with clear examples.

Open YouTube↗
Jenny's Lectures CS/IT · C Programming↗Instructor: Jenny's Lectures · Covers: Arrays, strings, pointers, structures, file handling, preprocessor

Clear step-by-step C explanations — great for semester lab preparation.

Open YouTube↗