✔ C-LANGUAGE CHAPTERS:-
1. C-Introduction
2. C-Constants
3. C-Basic Programs
4. C-Instructors
5. C-Operators
6. C-If Else Statement
7. C-Loop Contructs
8. C-Nesting Of Loops
9. C-Programming Examples
10. C-Functions
11. C-Functions Naming Convention
12. C-Pointers
13. C-Arrays
14. C-Arrays & Functions
15. C-Strings
16. C-Structures
17. C-Union
18. C-Storage Classes
19. C-PreProcessor
20. C-Header Files
21. C-R/W one Line
22. C-Accessing Random File
23. C-Important Point
24. C-Interview Questions
1. C-Introduction
2. C-Constants
3. C-Basic Programs
4. C-Instructors
5. C-Operators
6. C-If Else Statement
7. C-Loop Contructs
8. C-Nesting Of Loops
9. C-Programming Examples
10. C-Functions
11. C-Functions Naming Convention
12. C-Pointers
13. C-Arrays
14. C-Arrays & Functions
15. C-Strings
16. C-Structures
17. C-Union
18. C-Storage Classes
19. C-PreProcessor
20. C-Header Files
21. C-R/W one Line
22. C-Accessing Random File
23. C-Important Point
24. C-Interview Questions
Normally reading and accessing all had done sequentially i.e. start starting from the beginning with the first character and end till last. However, sometimes we need to access a word at the middle i.e. Called "Random Access". Random access allows us to access a particular data item located at anywhere in file.
For random access file processing two functions are used:
For random access file processing two functions are used:
- fseek()
- ftell()
Syntax: fseek(file pointer, number of characters, mode);
This function takes three arguments: First, the file pointer. Second, number of characters move to new position. Variable must be long integer for it. Third, mode that takes 0 and 1. 0 for positioning a pointer at beginning of the file 1 for relative current position where pointer is. 2 end of file. This function returns non zero value if successfully otherwise returns 0 in case of failure.
2. ftell(): - this function is used to return current position of pointer. It takes one argument. The return value is always a long integer.
Syntax: variable=ftell(file pointer);
Two types of files are there in C Programming:
- Text files
- Binary files
Text files only consists text information i.e. Alphabet, digits, symbols etc... Every these have ASCII code and in reality all ASCII codes of characters stored in text files.
For Eg: ASCII code of alphabet 'A' is 65.
Wherever, binary files only consists the bytes. For Eg: we store a images/pictures etc. They always store in a binary file.
In text binary, a special character whose ASCII value is 20 is inserted at the end of last character. This special character is used to indicate that the file is ended.
If that character is searched at anywhere in file, the read() would return EOF. No such an special character exists in binary file.
For Eg: ASCII code of alphabet 'A' is 65.
Wherever, binary files only consists the bytes. For Eg: we store a images/pictures etc. They always store in a binary file.
In text binary, a special character whose ASCII value is 20 is inserted at the end of last character. This special character is used to indicate that the file is ended.
If that character is searched at anywhere in file, the read() would return EOF. No such an special character exists in binary file.
In modes of text file only previously defined modes are used. While in binary files 'b' character is appended at every previously defined mode.
C-R/W One Line: Previous Next: C-Important Points
C-R/W One Line: Previous Next: C-Important Points