introduction, file, types of files, need for file handling, steps for processing a file, file input/out functions {declaraion of file, opening a file, reading data from a file, writing data in a file, closing the file}, programs #technology #computers
Contents:-
Introduction
What is a File?
High Level I/O Functions
Defining & Opening a File
Closing a File
The getc and putc Functions
The getw and putw Functions
The fprintf and fscanf Functions
Contents:-
Introduction
What is a File?
High Level I/O Functions
Defining & Opening a File
Closing a File
The getc and putc Functions
The getw and putw Functions
The fprintf and fscanf Functions
This video has covered FILES chapter in Data Structure using C for BCA II semester, as per syllabus prescribed by Karnatak University , Dharwad,Karnataka,INDIA.
This video has covered FILES chapter in Data Structure using C for BCA II semester, as per syllabus prescribed by Karnatak University , Dharwad,Karnataka,INDIA.
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
A file is a collection of related data stored as a unit with a name to identify it.
A file is a collection of related data that a computers treats as a single unit.
Computers stores files to secondary storage so that the contents of files remain intact when a computer shuts down.
When a computer reads a file, it copies the file from the storage device to memory. When it writes to a file, it transfers data from memory to the storage device.
C uses a structure called FILE(defined in stdio.h) to store the attributes of a file.
Discrete storage unit for data in the form of a stream of bytes.
Durable: stored in non-volatile memory.
Starting end, sequence of bytes, and end of stream (or end of file).
Sequential access of data by a pointer performing read / write / deletion / insertion.
Meta-data (information about the file) before the stream of actual data.
Richard's aventures in two entangled wonderlandsRichard Gill
Since the loophole-free Bell experiments of 2020 and the Nobel prizes in physics of 2022, critics of Bell's work have retreated to the fortress of super-determinism. Now, super-determinism is a derogatory word - it just means "determinism". Palmer, Hance and Hossenfelder argue that quantum mechanics and determinism are not incompatible, using a sophisticated mathematical construction based on a subtle thinning of allowed states and measurements in quantum mechanics, such that what is left appears to make Bell's argument fail, without altering the empirical predictions of quantum mechanics. I think however that it is a smoke screen, and the slogan "lost in math" comes to my mind. I will discuss some other recent disproofs of Bell's theorem using the language of causality based on causal graphs. Causal thinking is also central to law and justice. I will mention surprising connections to my work on serial killer nurse cases, in particular the Dutch case of Lucia de Berk and the current UK case of Lucy Letby.
Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...Travis Hills MN
Travis Hills of Minnesota developed a method to convert waste into high-value dry fertilizer, significantly enriching soil quality. By providing farmers with a valuable resource derived from waste, Travis Hills helps enhance farm profitability while promoting environmental stewardship. Travis Hills' sustainable practices lead to cost savings and increased revenue for farmers by improving resource efficiency and reducing waste.
Seminar of U.V. Spectroscopy by SAMIR PANDASAMIR PANDA
Spectroscopy is a branch of science dealing the study of interaction of electromagnetic radiation with matter.
Ultraviolet-visible spectroscopy refers to absorption spectroscopy or reflect spectroscopy in the UV-VIS spectral region.
Ultraviolet-visible spectroscopy is an analytical method that can measure the amount of light received by the analyte.
DERIVATION OF MODIFIED BERNOULLI EQUATION WITH VISCOUS EFFECTS AND TERMINAL V...Wasswaderrick3
In this book, we use conservation of energy techniques on a fluid element to derive the Modified Bernoulli equation of flow with viscous or friction effects. We derive the general equation of flow/ velocity and then from this we derive the Pouiselle flow equation, the transition flow equation and the turbulent flow equation. In the situations where there are no viscous effects , the equation reduces to the Bernoulli equation. From experimental results, we are able to include other terms in the Bernoulli equation. We also look at cases where pressure gradients exist. We use the Modified Bernoulli equation to derive equations of flow rate for pipes of different cross sectional areas connected together. We also extend our techniques of energy conservation to a sphere falling in a viscous medium under the effect of gravity. We demonstrate Stokes equation of terminal velocity and turbulent flow equation. We look at a way of calculating the time taken for a body to fall in a viscous medium. We also look at the general equation of terminal velocity.
This presentation explores a brief idea about the structural and functional attributes of nucleotides, the structure and function of genetic materials along with the impact of UV rays and pH upon them.
The use of Nauplii and metanauplii artemia in aquaculture (brine shrimp).pptxMAGOTI ERNEST
Although Artemia has been known to man for centuries, its use as a food for the culture of larval organisms apparently began only in the 1930s, when several investigators found that it made an excellent food for newly hatched fish larvae (Litvinenko et al., 2023). As aquaculture developed in the 1960s and ‘70s, the use of Artemia also became more widespread, due both to its convenience and to its nutritional value for larval organisms (Arenas-Pardo et al., 2024). The fact that Artemia dormant cysts can be stored for long periods in cans, and then used as an off-the-shelf food requiring only 24 h of incubation makes them the most convenient, least labor-intensive, live food available for aquaculture (Sorgeloos & Roubach, 2021). The nutritional value of Artemia, especially for marine organisms, is not constant, but varies both geographically and temporally. During the last decade, however, both the causes of Artemia nutritional variability and methods to improve poorquality Artemia have been identified (Loufi et al., 2024).
Brine shrimp (Artemia spp.) are used in marine aquaculture worldwide. Annually, more than 2,000 metric tons of dry cysts are used for cultivation of fish, crustacean, and shellfish larva. Brine shrimp are important to aquaculture because newly hatched brine shrimp nauplii (larvae) provide a food source for many fish fry (Mozanzadeh et al., 2021). Culture and harvesting of brine shrimp eggs represents another aspect of the aquaculture industry. Nauplii and metanauplii of Artemia, commonly known as brine shrimp, play a crucial role in aquaculture due to their nutritional value and suitability as live feed for many aquatic species, particularly in larval stages (Sorgeloos & Roubach, 2021).
Deep Behavioral Phenotyping in Systems Neuroscience for Functional Atlasing a...Ana Luísa Pinho
Functional Magnetic Resonance Imaging (fMRI) provides means to characterize brain activations in response to behavior. However, cognitive neuroscience has been limited to group-level effects referring to the performance of specific tasks. To obtain the functional profile of elementary cognitive mechanisms, the combination of brain responses to many tasks is required. Yet, to date, both structural atlases and parcellation-based activations do not fully account for cognitive function and still present several limitations. Further, they do not adapt overall to individual characteristics. In this talk, I will give an account of deep-behavioral phenotyping strategies, namely data-driven methods in large task-fMRI datasets, to optimize functional brain-data collection and improve inference of effects-of-interest related to mental processes. Key to this approach is the employment of fast multi-functional paradigms rich on features that can be well parametrized and, consequently, facilitate the creation of psycho-physiological constructs to be modelled with imaging data. Particular emphasis will be given to music stimuli when studying high-order cognitive mechanisms, due to their ecological nature and quality to enable complex behavior compounded by discrete entities. I will also discuss how deep-behavioral phenotyping and individualized models applied to neuroimaging data can better account for the subject-specific organization of domain-general cognitive systems in the human brain. Finally, the accumulation of functional brain signatures brings the possibility to clarify relationships among tasks and create a univocal link between brain systems and mental functions through: (1) the development of ontologies proposing an organization of cognitive processes; and (2) brain-network taxonomies describing functional specialization. To this end, tools to improve commensurability in cognitive science are necessary, such as public repositories, ontology-based platforms and automated meta-analysis tools. I will thus discuss some brain-atlasing resources currently under development, and their applicability in cognitive as well as clinical neuroscience.
What is greenhouse gasses and how many gasses are there to affect the Earth.moosaasad1975
What are greenhouse gasses how they affect the earth and its environment what is the future of the environment and earth how the weather and the climate effects.
ANAMOLOUS SECONDARY GROWTH IN DICOT ROOTS.pptxRASHMI M G
Abnormal or anomalous secondary growth in plants. It defines secondary growth as an increase in plant girth due to vascular cambium or cork cambium. Anomalous secondary growth does not follow the normal pattern of a single vascular cambium producing xylem internally and phloem externally.
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...University of Maribor
Slides from talk:
Aleš Zamuda: Remote Sensing and Computational, Evolutionary, Supercomputing, and Intelligent Systems.
11th International Conference on Electrical, Electronics and Computer Engineering (IcETRAN), Niš, 3-6 June 2024
Inter-Society Networking Panel GRSS/MTT-S/CIS Panel Session: Promoting Connection and Cooperation
https://www.etran.rs/2024/en/home-english/
Professional air quality monitoring systems provide immediate, on-site data for analysis, compliance, and decision-making.
Monitor common gases, weather parameters, particulates.
2. CONTENT-
INTRODUCTION
WHAT IS A FILE?
TYPES OF FILES
NEED OF FILE HANDLING
STEPS FOR PROCESSING A FILE
FILE INPUT/OUTPUT FUNCTIONS
DECLARATION OF A FILE
OPENING OF A FILE
READING DATA FROM A FILE
WRITING DATA IN A FILE
CLOSING THE FILE
PROGRAMS
3. WHAT IS A FILE?
A FILE IS A COLLECTION OF DATA STORED IN ONE UNIT,
IDENTIFIED BY A FILENAME.
IT CAN BE A DOCUMENT, PICTURE, AUDIO OR VIDEO STREAM,
DATA LIBRARY, APPLICATION, OR OTHER COLLECTION OF DATA.
FILES CAN BE OPENED, SAVED, DELETED, AND MOVED TO
DIFFERENT FOLDERS.
THEY CAN ALSO BE TRANSFERRED ACROSS NETWORK
CONNECTIONS OR DOWNLOADED FROM THE INTERNET.
A FILES TYPE CAN BE DETERMINED BY VIEWING THE FILES
ICON OR BY READING THE FILE EXTENSION.
4. INTRODUCTION
FILE HANDLING IS STORING OF DATA IN A FILE USING A
PROGRAM.
WE CAN EXTRACT/ FETCH DATA FROM A FILE TO WORK WITH
IT IN THE PROGRAM.
FILES ARE USED TO STORE DATA IN A STORAGE DEVICE
PERMANENTLY.
FILE HANDLING PROVIDES A MECHANISMTO STORE THE
OUTPUT OF A PROGRAM IN A FILE AND TO PERFORM VARIOUS
OPERATIONS ON IT.
5. TYPES OF FILES
TEXT FILES - IT IS THE DEFAULT MODE OF A FILE.
EACH LINE IN A TEXT FILE IS TERMINATED WITH THE SPECIAL
CHARACTER KNOWN AS END OF LINE. THE EXTENSION OF TEXT
FILE IS .txt.
BINARY FILES – IT CONTAINS SAME FORMAT IN WHICH THE
INFORMATION IS HELD IN THE MEMORY. NO TRANSLATIONS ARE
REQUIRED IN THIS FILE.
CSV FILES – THIS IS THE COMMA SEPARATED VALUES FILE, WHICH
ALLOWS DATA TO BE SAVED IN TABULAR FORM. THESE ARE USE
TEXT FILES BINARY
FILES
CSV FILES
6. need of file handling
A FILE IN ITSELF IS A BUNCH OF BYTES STORED ON
SOME STORAGE DEVICE.
FILE HELPS US TO STORE DATA PERMANENTLY, WHICH
CAN BE RETRIEVED IN FUTURE.
C - LANGUAGE PROVIDES A CONCEPT OF FILE THROUGH
WHICH DATA CAN BE STORED ON A DISK OR
SECONDARY STORAG DEVICE.
THE STORED DATA CAN BE RETRIEVED WHENEVER
NEEDED.
FILE HANDLING IS REQUIREDTO STORE THE OUTPUT OF
THE PREOGRAM WHICH CAN BE USED IN THE FUTURE.
NO MATTER WHATEVER APPLICATION WE DEVELOP , WE
NEED TO STORE THAT DATA SOMEWHERE, AND HERE
DATA HANDLING COMES INTO PLAY.
7. STEPS FOR PROCESSING A
FILE
DECLARE A FILE POINTER VARIABLE
OPEN A FILE USING fopen() function
PROCESS THE FILE USING SUITABLE
FUNCTION
CLOSE THE FILE USING fclose()
function
9. DECLARATION OF A FILE
POINTER
• The type of file that is to be used must
be specified
• This is accomplished by using a
VARIABLE called FILE POINTER (fp)
• Pointer variable that points to a structure FILE
• The members of the FILE structure are used by the
program in various file access operations, but
programmers do not need to be concerned about
them.
• For each file that is to be OPENED, a
pointer type FILE must be declared.
FILE is a structure declared in stdio.h
10. When the function fopen() is called, that function
creates an instance of the FILE structure and
returns a pointer to that structure .
This pointer is used in all subsequent operations
on the file.
The SYNTAX for declaring file pointers is as
follows; FILE *file_pointer_name,…;
FILE *fp;
11. OPENING A FILE: FOR
CREATION AND EDIT
Opening a file is performed using the fopen() function
defined in the stdio.h header file.
The syntax for opening a file in standard I/O is:
Function fopen takes the name of a file as it's 1st
parameter
And mode as it's 2nd parameter.
The string given as first parameter for filename, opens
the file named and assigns an identifier to the FILE type
pointer fp.
This pointer, which contains all the information about
the file is subsequently used as a communication link
between the system and program.
The string given as second parameter for mode,
FILE
*fopen("filename","mode");
12. A filename in a C program can also contain path information
The path specifies the drive and/or directory or folder name
where the file is located.
If a filename is specified without a path, it will be assumed
that the file is located wherever the operating system
currently designates as the default.
On PCs, the backslash character ( ) is used to separate
directory names in a path.
It is to be remembered that the backslash character has a
special meaning to C with respect to escape sequence when it
is in a string. To represent the backslash character itself, one
must precede it with another backslash.
Thus, in a C program, the filename would be represented as
follows.
“c:examdatalist.txt”;
Directory
name
Drive
name
File
name
13. Mode can be one of the following;
If the purpose is " reading" and if it exists, then the file is opened
with current contents safe otherwise an error occurs.
When the mode is " writing", a file with the specialised name is
created, if the file does not exist. The contents are deleted, if the
file already exists.
When the purpose is " appending", the file is opened with the
current contents safe. A file with the specified name is created if
the file does not exist.
14. These statements are used to create a text file with
the name data.dat under current directory
It is opened in "w" mode as data are to be written into
the file data.dat
FILE *fp;
fp =
fopen("data.dat","w");
Following is an example where a file pointer “ fp” is declared, the file
name, which is declared to contain a maximum of 80 characters, is
obtained from the keyboard and then the file is opened in the “write”
mode.
char filename[80];
FILE *fp;
printf(“Enter the filename to be
opened”);
gets(fi lename);
fp = fopen(fi lename,“w”);
15. Writing data In a file
C provides four functions that can be used to
write text file into the disk. These are;
fprintf()
fputs()
fputc()
fwrite()
They are just the file versions of printf() puts()
putc() write()
The only difference is that fprintf() fputs()
fputc() fwrite() expects a pointer to the structure
FILE.
16. EXAMPLE; Write to a text file
#include <stdio.h>
#include <stdlib.h>
int main()
{
int num;
FILE *fptr
fptr = fopen("C:program.txt","w");
if(fptr == NULL)
{
printf("Error!");
exit(1);
}
printf("Enter num: ");
scanf("%d",&num);
fprintf(fptr,"%d",num);
fclose(fptr);
return 0;
}
17. Writing to a binary file
To write into a binary file, we need to use the
fwrite() function. The functions take 4
arguments:
1. Address of data to be written in the disk
2. Size of data to be written in the disk
3. Number of such type of data
4. Pointer to the file where you want to write
fwrite(addressData, sizeData, numbersData,
pointerToFile);
19. Reading data from a file
C provides 4 functions that can be used to read text
files from the disk
fscanf()
fgets()
fgetc()
fread()
These are just the file versions of scanf() gets()
getc() and read()
The only difference is that fscanf() fgets() fgetc()
and fread() expects a pointer to the structural FILE.
20. EXAMPLE: Read from a text file
#include <stdio.h>
#include <stdlib.h>
int main()
{
int num;
FILE *fptr;
if ((fptr = fopen("C:program.txt","r")) == NULL){
printf("Error! opening file");
exit(1);
}
fscanf(fptr,"%d", &num);
printf("Value of n=%d", num);
fclose(fptr);
return 0;
}
21. READ FROM A BINARY FILE
Function fread() takes 4 arguments:
1. Address of data to be written in the disk
2. Size of data to be written in the disk
3. Number of such type of data
4. Pointer to the file where you want to read
fread(addressData, sizeData, numbersData,
pointerToFile)
22. Read from a binary file using fread()
#include <stdio.h>
#include <stdlib.h>
struct threeNum
{
int n1, n2, n3;
};
int main()
{
int n;
struct threeNum num;
FILE *fptr;
if ((fptr = fopen("C:program.bin","rb")) == NULL){
printf("Error! opening file");
exit(1);
}
for(n = 1; n < 5; ++n)
{
fread(&num, sizeof(struct threeNum), 1, fptr);
printf("n1: %dtn2: %dtn3: %d", num.n1, num.n2, num.n3);
}
fclose(fptr);
return 0:
}
23. Closing a file
The file (both text and binary) should be closed
after readingwriting.
Closing a file is performed using the fclose()
function.
Here, fptr is a file pointer associated with the
file to be closed.
fclose() returns 0 on success or –1 on error
fclose(fptr)
24. When a program terminates
(either by reaching the end of main() or by
executing the exit() function)
All streams are automatically flushed and
closed.
Actually, in a simple program, it is not
necessary to close the file because the system
closes all open files before returning to the
operating system.
25. programs
To open a file, write in it,
and close the file
To open a file, read from
it, and close the file