Unit V: Input/Output and Low-Level Programming

Table of Contents

1. Standard Input and Output

C provides a set of standard library functions for input and output operations, primarily defined in the stdio.h header file.


2. Data Files and Processing

File handling allows programs to store data permanently on a disk.


3. Low-Level Programming

C allows programmers to perform tasks that are typically the domain of assembly language, providing close control over hardware.


4. Bitwise Operations and Fields

Bitwise operations allow for the manipulation of individual bits within a data type.

Operator Name Description
& Bitwise AND Sets bit to 1 if both corresponding bits are 1.
| Bitwise OR Sets bit to 1 if at least one corresponding bit is 1.
^ Bitwise XOR Sets bit to 1 if bits are different.
~ Bitwise NOT Flips all bits.
<< Left Shift Shifts bits to the left, filling with zeros.

5. Preprocessor and Macros

The C Preprocessor is a tool that examines the code before actual compilation begins.

Common Directives: #define, #include, #ifdef, #ifndef, #else, #endif.

6. Command Line Arguments

Command line arguments allow users to pass parameters to the main() function when the program is executed from the terminal.

Exam Tips

Frequently Asked Questions

Q: What is the difference between text and binary files?
Text files store data as sequences of characters (human-readable), while binary files store data exactly as it is represented in memory.

Q: Why use bit-fields?
They are used when memory is extremely limited or when you need to match a specific hardware register format.