This document discusses low-level input/output in C programming. It explains that low-level I/O provides direct access to files and devices using functions like open(), close(), read(), write(), and lseek(). These functions take a file descriptor as a parameter and allow accessing files sequentially or randomly. The document also covers error handling using errno values and differentiates between high-level and low-level I/O.
File Operation such as
Reading the file content
Writing the content to the file
Copying the content from one file to another file
Counting the number of character, words and lines of the file
This PPT discusses the concept of Dynamic Linker as in Linux and its porting to Solaris ARM platform. It starts from the very basics of linking process
File Operation such as
Reading the file content
Writing the content to the file
Copying the content from one file to another file
Counting the number of character, words and lines of the file
This PPT discusses the concept of Dynamic Linker as in Linux and its porting to Solaris ARM platform. It starts from the very basics of linking process
This is an intermediate conversion course for C++, suitable for second year computing students who may have learned Java or another language in first year.
FISL XIV - The ELF File Format and the Linux LoaderJohn Tortugo
These are the slides used in a lecture I gave in the XIV International Board on Free Software. In this lecture I gave a brief overview of the ELF specification (the ELF specification is a document describing the format of executable, shared libraries and relocatable objects files used in Linux and many others operating systems) and the Linux dynamic loader (which is a program that acts together with the OS to create and initialize a program address space among others tasks).
This is an intermediate conversion course for C++, suitable for second year computing students who may have learned Java or another language in first year.
FISL XIV - The ELF File Format and the Linux LoaderJohn Tortugo
These are the slides used in a lecture I gave in the XIV International Board on Free Software. In this lecture I gave a brief overview of the ELF specification (the ELF specification is a document describing the format of executable, shared libraries and relocatable objects files used in Linux and many others operating systems) and the Linux dynamic loader (which is a program that acts together with the OS to create and initialize a program address space among others tasks).
* What are Embedded Systems?
* C for Embedded Systems vs. Embedded C.
* Code Compilation process.
* Error types.
* Code Compilation using command line.
C is mother language of all programming language.
It is a system programming language. It is a procedure-oriented programming language. It is also called mid-level programming language.
C evolved from a language called B, written by Ken Thompson at Bell Labs in 1970. Ken used B to write one of the first implementations of UNIX. B in turn was a descendant of the language BCPL (developed at Cambridge (UK) in 1967), with most of its instructions removed.
So many instructions were removed in going from BCPL to B, that Dennis Ritchie of Bell Labs put some back in (in 1972), and called the language C.
The famous book The C Programming Language was written by Kernighan and Ritchie in 1978, and was the definitive reference book on C for almost a decade.
The original C was still too limiting, and not standardized, and so in 1983, an ANSI committee was established to formalize the language definition.
It has taken until now (ten years later) for the ANSI ( American National Standard Institute) standard to become well accepted and almost universally supported by compilers.
This is ppt prsented by me in class in this ppt i include file handling in which i tell us about the types of files
creation of text file in C ++ ,updating a text file in C++ , printing the inforamtion in text file .creation of binary file in C ++ ,updating a binary file in C++ , printing the inforamtion in binary file, text file function and binary file function in c++ , File ponters ,syntax of every thing and use of file pointers and many more.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Safalta Digital marketing institute in Noida, provide complete applications that encompass a huge range of virtual advertising and marketing additives, which includes search engine optimization, virtual communication advertising, pay-per-click on marketing, content material advertising, internet analytics, and greater. These university courses are designed for students who possess a comprehensive understanding of virtual marketing strategies and attributes.Safalta Digital Marketing Institute in Noida is a first choice for young individuals or students who are looking to start their careers in the field of digital advertising. The institute gives specialized courses designed and certification.
for beginners, providing thorough training in areas such as SEO, digital communication marketing, and PPC training in Noida. After finishing the program, students receive the certifications recognised by top different universitie, setting a strong foundation for a successful career in digital marketing.
This slide is special for master students (MIBS & MIFB) in UUM. Also useful for readers who are interested in the topic of contemporary Islamic banking.
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Dr. Vinod Kumar Kanvaria
Exploiting Artificial Intelligence for Empowering Researchers and Faculty,
International FDP on Fundamentals of Research in Social Sciences
at Integral University, Lucknow, 06.06.2024
By Dr. Vinod Kumar Kanvaria
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
C programming session 14
1. Slide 1 of 22Ver. 1.0
Programming in C
Objectives
In this session, you will learn to:
Differentiate between high-level and low-level input/output
Work with low-level input/output functions
Use random access in files
2. Slide 2 of 22Ver. 1.0
Programming in C
Differentiating Between High-Level and Low-Level Input/Output
In C, files and devices can be accessed by using two
groups of functions:
High-level I/O or stream-level I/O
Low-level I/O
3. Slide 3 of 22Ver. 1.0
Programming in C
Difference Between High-level I/O and Low-level I/O
High-level or Stream-level I/O:
Is more flexible and convenient.
Hides complexity from the programmer.
Is slower.
Low-level I/O:
Provides direct access to files and devices.
Is complex (buffer management is to be done by the
programmer).
Is faster.
Uses a file descriptor to track the status of the file.
4. Slide 4 of 22Ver. 1.0
Programming in C
Practice: 8.1
Which of the following statements is true?
In C, there are many interfaces between a program and
peripheral devices.
A file descriptor is a non-negative integer.
When you perform an operation on a file, the system uses the
name of the file to identify it.
5. Slide 5 of 22Ver. 1.0
Programming in C
Practice: 8.1 (Contd.)
Solution:
A file descriptor is a non-negative integer.
6. Slide 6 of 22Ver. 1.0
Programming in C
Low-level I/O functions are used for:
Accessing files and devices directly.
Reading binary files in large chunks.
Performing I/O operations quickly and efficiently.
Uses of Low-Level Input/Output
7. Slide 7 of 22Ver. 1.0
Programming in C
The low-level I/O system in C provides functions that can be
used to access files and devices.
The basic low-level I/O functions are:
open()
close()
read()
write()
Working with Low-Level Input/Output Functions
8. Slide 8 of 22Ver. 1.0
Programming in C
The open() function:
Is used to open an existing file or create a new file.
Returns a file descriptor for the file name passed to it.
Has the following syntax:
int open(char *filename, int flags, int perms
);
The open() Function
9. Slide 9 of 22Ver. 1.0
Programming in C
The close() function:
Closes the file that was opened using the open() function.
Takes the file descriptor as a parameter to close the file.
Returns 0 on success and -1 in case of an error.
Has the following syntax:
int close(int filedes);
The close() Function
10. Slide 10 of 22Ver. 1.0
Programming in C
The read() function:
Reads data from a file.
Starts reading a file from the current file position.
Has the following syntax:
int read (int filedes, char *buffer, int
size);
The read() function
11. Slide 11 of 22Ver. 1.0
Programming in C
The write() function:
Enables a user to write contents to a file.
Has the following syntax:
int write (int filedes, char *buffer, int
size);
The write() function
12. Slide 12 of 22Ver. 1.0
Programming in C
Practice: 8.2
1. Which of the following statements is true?
a. At end-of-file, if a function is called repeatedly, it will give error.
b. In a read() function, the value of zero indicates end-of-file.
2. What will happen if you do not call the write() function in
a loop?
13. Slide 13 of 22Ver. 1.0
Programming in C
Solution:
1. In a read() function, the value of zero indicates end-of-file.
2. If you do not call write() function in a loop then the entire
data would not be written.
Practice: 8.2 (Contd.)
14. Slide 14 of 22Ver. 1.0
Programming in C
Error Handling:
Some of the low-level I/O functions return error flags when they
fail to perform a specified task.
You can find these types of errors using a variable, errno.
The following table lists some values of errno that are
common to the open(), close(), read(), and write()
functions.
Error Handling
errno values Description
EACCES Specifies that the program has failed to access one of the directories
in the file.
ENAMETOOLONG Indicates that the file name is too long.
ENOSPC Specifies that the disc is out of space and the file can not be created.
EIO Specifies that there was a hardware error.
EBADF Specifies that the file descriptor passed to read, write, or close the
file is invalid.
15. Slide 15 of 22Ver. 1.0
Programming in C
There are certain errno values that are specific to the
open() function, which are shown with the help of the
following table.
errno values Description
EEXIST Specifies that if File already exists, and O_CREAT and O_EXCL are
set, then opening the file would conflict with the existing file and the
file will not open.
EISDIR Specifies that the file is actually a directory.
ENOENT Specifies that some of the file components do not exist.
EMFILE Specifies that too many files are open.
EROFS Specifies that the file is on a read only systembut either one of the
write permissions O_WRONLY, O_RDWR, or O_TRUNC is set.
Error Handling (Contd.)
16. Slide 16 of 22Ver. 1.0
Programming in C
There are certain errno values that are specific to the
write() function, which are shown with the help of the
following table.
errno values Description
EFBIG Specifies that the file will become too large if the
data is written on it.
EINTR Specifies that the write operation is temporarily
interrupted.
Error Handling (Contd.)
17. Slide 17 of 22Ver. 1.0
Programming in C
The read and write operations on files are usually sequential
in nature.
Random access permits non-sequential file access so that a
file can be read or written out of sequence.
Random access in low-level file routines is performed using
the lseek() function.
Using Random Access Seek in Files
18. Slide 18 of 22Ver. 1.0
Programming in C
The lseek() function:
Returns the file position, as measured in bytes from the
beginning of the file.
Has the following syntax:
long lseek (int filedes, long offset, int
origin);
The lseek() Function
19. Slide 19 of 22Ver. 1.0
Programming in C
The following table lists the various values of the third
parameter (origin).
The lseek() Function (Contd.)
Values for origin Description
SEEK_SET or 0 Specifies that the offset is relative to the
beginning of the file. The offset can only be
positive.
SEEK_CUR or 1 Specifies that the offset is relative to the current
position. The offset can be positive or negative.
SEEK_END or 2 Specifies that the offset is relative to the end of
the file. The offset can be positive or negative.
20. Slide 20 of 22Ver. 1.0
Programming in C
The following table lists some instructions for moving to the
end or beginning of a file.
The lseek() Function (Contd.)
Instruction Function used
To get to the end of a file lseek(filedes,0,2);
To return to the beginning of a file lseek(filedes,0,0);
21. Slide 21 of 22Ver. 1.0
Programming in C
Summary
In this session, you learned that:
In C, files and devices can be accessed by using high-level I/O
or stream-level I/O and low-level I/O.
Low-level I/O functions are those, which provide direct access
to files and peripheral devices.
A file descriptor is a non-negative integer, which is returned by
the open() function and is used in read() and write()
functions. It tells about the permission to access the file.
Low-level input/output functions are used for the following
purposes:
Accessing files and devices directly
Reading the binary files in large chunks
Performing I/O operations quickly and efficiently
The open() function is used to open or create a file.
22. Slide 22 of 22Ver. 1.0
Programming in C
Summary (Contd.)
The close() function is used for closing the file.
The read() function reads the existing file up to specified size
and stores it into a character array.
The write() function writes on the file taking input from a
character array up to specified size.
Most of the low-level I/O functions throw errors during file
handling.
errno is the variable that tells about the error occurred during
a low-level I/O operation.
Files and devices can also be accessed randomly.
The lseek() function is used to place the file position to the
desired place.
The lseek() function do not require to read or write the file
for positioning it.
Editor's Notes
Begin the session by explaining the objectives of the session.
Give examples where low-level and I/O can be used.
Use this slide to test the student’s understanding on high-level and low-level I/O.
Give a scenario and ask the students which type of I/O they would use in the situation. Also, ask them to justify their answers.
Tell the students that the value returned by the open() function can be used to check whether a file has been opened successfully.
The close() function releases the resources occupied. It also flushes out the data from the streams before closing them.
If successful, the read() functions returns the number of characters read.
If successful, the write function returns the number of bytes written into the file. This number should be equal to the size parameter of the write function.
Use this slide to test the student’s understanding on low-level I/O functions.
Use this and the next slide to summarize the session.