6) Arrays and Strings in C:
- Arrays: Arrays are a collection of elements of the same data type stored in
contiguous memory locations. In C, arrays are declared with a fixed size and can
store elements of any data type. They provide a convenient way to store and
access multiple values of the same type under a single name.
- Strings: In C, strings are represented as arrays of characters terminated by a
null character '\0'. C does not have a built-in string data type like other
programming languages. Instead, strings are represented as character arrays.
- Syntax:
- Array Declaration: `datatype array_name[size];`
- String Declaration: `char string_name[size];` char a[6]; a[0] =C, a[1]= a,
a[2]=n, a[3]=a, a[4]=d, a[5]=a
7) File Handling in C (Basic Overview):
- File handling in C involves operations such as creating, opening, reading,
writing, and closing files. Files in C are handled using pointers to structures that
represent file streams.
- Basic operations:
- Opening a file: `fopen()`
- Reading from a file: `fscanf()`, `fgets()`, etc.
- Writing to a file: `fprintf()`, `fputs()`, etc.
- Closing a file: `fclose()`
- Syntax:
- Opening a file: `FILE *fptr = fopen("filename", "mode");`
- Reading from a file: `fscanf(fptr, format_specifiers, &variables);`
- Writing to a file: `fprintf(fptr, format_specifiers, variables);`
- Closing a file: `fclose(fptr);`