This document discusses pointers to structures and arrays in C programming. It explains how to declare a pointer to a structure, access members of a structure using pointer operators like -> and *, and define pointers to arrays of strings. It also covers pointers to pointers, opening and closing files, reading from and writing to files, and how to create and manage files in C.
Data may be organized in many different ways; the logical or mathematical model of a particular organization of data is called "Data Structure". The choice of a particular data model depends on two considerations:
It must be rich enough in structure to reflect the actual relationships of the data in the real world.
The structure should be simple enough that one can effectively process the data when necessary.
Data Structure Operations
The particular data structure that one chooses for a given situation depends largely on the nature of specific operations to be performed.
The following are the four major operations associated with any data structure:
i. Traversing : Accessing each record exactly once so that certain items in the record may be processed.
ii. Searching : Finding the location of the record with a given key value, or finding the locations of all records which satisfy one or more conditions.
iii. Inserting : Adding a new record to the structure.
iv. Deleting : Removing a record from the structure.
Primitive and Composite Data Types
Primitive Data Types are Basic data types of any language. In most computers these are native to the machine's hardware.
Some Primitive data types are:
Integer
Concept and Definition of Data Structures
Introduction to Data Structures: Information and its meaning, Array in C++: The array as an ADT, Using one dimensional array, Two dimensional array, Multi dimensional array, Structure , Union, Classes in C++.
https://github.com/ashim888/dataStructureAndAlgorithm
Data Structure is the specific method for sorting out the data in a system with the goal that it could be utilized efficiently. These can implement at least one specific abstract data types (ADT), which indicate the operations that can be performed on the data structure and the computational unpredictability of those operations. Copy the link given below and paste it in new browser window to get more information on Data Structure & Algorithms:- www.transtutors.com/homework-help/computer-science/data-structure-and-algorithms.aspx
Data may be organized in many different ways; the logical or mathematical model of a particular organization of data is called "Data Structure". The choice of a particular data model depends on two considerations:
It must be rich enough in structure to reflect the actual relationships of the data in the real world.
The structure should be simple enough that one can effectively process the data when necessary.
Data Structure Operations
The particular data structure that one chooses for a given situation depends largely on the nature of specific operations to be performed.
The following are the four major operations associated with any data structure:
i. Traversing : Accessing each record exactly once so that certain items in the record may be processed.
ii. Searching : Finding the location of the record with a given key value, or finding the locations of all records which satisfy one or more conditions.
iii. Inserting : Adding a new record to the structure.
iv. Deleting : Removing a record from the structure.
Primitive and Composite Data Types
Primitive Data Types are Basic data types of any language. In most computers these are native to the machine's hardware.
Some Primitive data types are:
Integer
Concept and Definition of Data Structures
Introduction to Data Structures: Information and its meaning, Array in C++: The array as an ADT, Using one dimensional array, Two dimensional array, Multi dimensional array, Structure , Union, Classes in C++.
https://github.com/ashim888/dataStructureAndAlgorithm
Data Structure is the specific method for sorting out the data in a system with the goal that it could be utilized efficiently. These can implement at least one specific abstract data types (ADT), which indicate the operations that can be performed on the data structure and the computational unpredictability of those operations. Copy the link given below and paste it in new browser window to get more information on Data Structure & Algorithms:- www.transtutors.com/homework-help/computer-science/data-structure-and-algorithms.aspx
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
JIMS Vasant Kunj-II is one of the best BCA colleges in Delhi NCR. The Course content provided to BCA students are well updated and as per the Demand of the IT Industry. It helps to get Placements in Top IT Companies.
This Pdf includes the Details of File Handling in C. This comes in Unit IV.
COURSE TITLE: SOFTWARE DEVELOPMENT VI
COURSE CODE: VIT 351
TOPICS COVERED:
FILES
FILES I/O STREAM
TYPES OF FILES
DRAWBACKS OF TRADITIONAL METHOD OF DATA STORAGE
CONCEPT OF BUFFER
MODES OF FILE OPENING
END OF FILE
PROCESSORS DIRECTIVES
MACROS
TYPES OF MACROS
DIFFERENCE BETWEEN MACROS AND FUNCTIONS
QUIZ SET 5
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.
At the end of this lecture students should be able to;
Define the C standard functions for managing file input output.
Apply taught concepts for writing programs.
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.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
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.
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Normal Labour/ Stages of Labour/ Mechanism of LabourWasim Ak
Normal labor is also termed spontaneous labor, defined as the natural physiological process through which the fetus, placenta, and membranes are expelled from the uterus through the birth canal at term (37 to 42 weeks
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
1. Introduction to Data Structures
Affiliated KSWU, Vijayapura
Subscribe to my channel: http://www.youtube.com/c/SPSajjan
Facebook Page : https://www.facebook.com/sajjanvsl
website: http://sajjanvsl.blogspot.com
2. Pointer to a Structure in C
We have already learned that a pointer is a
variable which points to the address of another
variable of any data type like int, char, float etc.
Similarly, we can have a pointer to structures, where a
pointer variable can point to the address of a structure
variable. Here is how we can declare a pointer to a
structure variable.
3. Pointer to array of string
struct dog
{
char name[10];
char breed[10];
int age; char color[10];
}; struct dog spike; // declaring a pointer to a structure of type struct
dog struct dog *ptr_dog
4. 1 : Printing Address of the Character Array
Here's how you can create pointers to structs.
struct name {
member1;
member2;
.
.
};
int main()
{
struct name *ptr, Harry;
}
Here, ptr is a pointer to struct.
5. Accessing members using Pointer
There are two ways of accessing members of structure using pointer:
Using indirection (*) operator and dot (.) operator.
Using arrow (->) operator or membership operator.
Let's start with the first one.
6. Using Indirection (*) Operator and Dot (.) Operator
At this point ptr_dog points to the structure variable spike, so by dereferencing
it we will get the contents of the spike. This means spike and *ptr_dog are
functionally equivalent. To access a member of structure
write *ptr_dog followed by a dot(.) operator, followed by the name of the
member. For example:
(*ptr_dog).name - refers to the name of dog
(*ptr_dog).breed - refers to the breed of dog
and so on.
Parentheses around *ptr_dog are necessary because the precedence of dot(.)
operator is greater than that of indirection (*) operator.
7. Using arrow operator (->)
The above method of accessing members of the structure using pointers is slightly
confusing and less readable, that's why C provides another way to access
members using the arrow (->) operator. To access members using arrow (->)
operator write pointer variable followed by -> operator, followed by name of the
member.
1 2
ptr_dog->name // refers to the name of dog ptr_dog->breed // refers to the breed
of dog
and so on.
Here we don't need parentheses, asterisk (*) and dot (.) operator. This method is
much more readable and intuitive.
8. C - Pointer to Pointer
A pointer to a pointer is a form of multiple indirection, or a chain of pointers.
Normally, a pointer contains the address of a variable. When we define a pointer
to a pointer, the first pointer contains the address of the second pointer, which
points to the location that contains the actual value as shown below.
Pointer to Pointer in C
A variable that is a pointer to a pointer must be declared as such. This is done by
placing an additional asterisk in front of its name. For example, the following
declaration declares a pointer to a pointer of type int −
int **var;
9. When a target value is indirectly pointed to by a pointer to a pointer, accessing
that value requires that the asterisk operator be applied twice, as is shown
below in the example −
#include <stdio.h>
int main () {
int var;
int *ptr;
int **pptr;
var = 3000;
/* take the address of var */
ptr = &var;
/* take the address of ptr using address of operator & */
pptr = &ptr;
10. /* take the value using pptr */
printf("Value of var = %dn", var );
printf("Value available at *ptr = %dn", *ptr );
printf("Value available at **pptr = %dn", **pptr);
return 0;
}
When the above code is compiled and executed, it produces the following result
−
Value of var = 3000
Value available at *ptr = 3000
Value available at **pptr = 3000
12. Declaring, Opening & Closing File Streams in C Programming
This lesson explains handling file operations, like opening
and closing a file, in C programming. You will also learn how
to perform read and write operations on a file. Various
examples are shown to understand file streams.
Handling File Streams in C
A file can be treated as external storage. It consists of a sequence of
bytes residing on the disk. Groups of related data can be stored in a
single file. A program can create, read, and write to a file. Unlike an
array, the data in the file is retained even after the program finishes its
execution. It's a permanent storage medium.
13. Declaring a File Pointer
In C language, in order to declare a file, we use a file pointer. A
file pointer is a pointer variable that specifies the next byte to
be read or written to. Every time a file is opened, the file pointer
points to the beginning of the file. A file is declared as follows:
FILE *fp;
//fp is the name of the file pointer
14. Opening, Creating, Closing
C language provides a number of functions to perform file
handling. fopen() is used to create a new file or open an existing
file. The syntax is as follows:
fp = FILE *fopen(const char *filename, const char *mode);
fp is the file pointer that holds the reference to the file,
the filename is the name of the file to be opened or created,
and mode specifies the purpose of opening a file such as for
reading or writing. FILE is an object type used for storing
information about the file stream.
A file can be opened in different modes. Below are some of the
most commonly used modes for opening or creating a file.
15. r : opens a text file in reading mode.
w : opens or creates a text file in writing mode.
a : opens a text file in append mode.
r+ : opens a text file in both reading and writing mode. The file must exist.
w+ : opens a text file in both reading and writing mode. If the file exists, it's
truncated first before overwriting. Any old data will be lost. If the file doesn't exist,
a new file will be created.
a+ : opens a text file in both reading and appending mode. New data is appended
at the end of the file and does not overwrite the existing content.
rb : opens a binary file in reading mode.
wb : opens or creates a binary file in writing mode.
ab : opens a binary file in append mode.
rb+ : opens a binary file in both reading and writing mode, and the original
content is overwritten if the file exists.
wb+: opens a binary file in both reading and writing mode and works similar to the
16. w+ mode for binary files. The file content is deleted first and then
new content is added.
ab+: opens a binary file in both reading and appending mode and
appends data at the end of the file without overwriting the existing
content.
A file needs to be closed after a read or write operation to release
the memory allocated by the program. In C, a file is closed using
the fclose() function. This returns 0 on success and EOF in the case
of a failure. An EOF is defined in the library called stdio.h. EOF is a
constant defined as a negative integer value which denotes that the
end of the file has reached.
fclose( FILE *fp );
17. Writing and Reading
Now that you've learned how to create a file in various modes and also how to
close a file, you must be wondering: how would you perform input and output
operations in a file? The fputc() and fputs() functions are used to write
characters and strings respectively in a file. Let's see how it's used.
int fputc( int c, FILE *fp );
This function writes a character c into the file with the help of the file pointer fp.
It returns EOF in the case of an error.
int fputs( const char *s, FILE *fp );
This function writes string s to the file with the help of the reference pointer fp.
The fgetc(), fgets(), and fscanf() are functions used in C programming language
to read characters or strings from a file. Let's discuss these, one by one.
18. How to Create a File
1. Whenever you want to work with a file, the first step is to create a
file. A file is nothing but space in a memory where data is stored.
2. To create a file in a 'C' program following syntax is used,
3. FILE *fp; fp = fopen ("file_name", "mode");
4. In the above syntax, the file is a data structure which is defined in
the standard library.
5. fopen is a standard function which is used to open a file.
6. If the file is not present on the system, then it is created and then
opened.
7. If a file is already present on the system, then it is directly opened
using this function.
8. fp is a file pointer which points to the type file.
19. Example:
#include <stdio.h>
int main() {
FILE *fp;
fp = fopen ("data.txt", "w");
}
Output:
File is created in the same folder where you have saved your code.
20. How to Close a fileExample:
FILE *fp; fp = fopen ("data.txt", "r"); fclose (fp);
The fclose function takes a file pointer as an argument. The file
associated with the file pointer is then closed with the help of
fclose function. It returns 0 if close was successful and EOF (end of
file) if there is an error has occurred while file closing.
After closing the file, the same file pointer can also be used with
other files.
In 'C' programming, files are automatically close when the program
is terminated. Closing a file manually by writing fclose function is a
good programming practice
21. Writing to a File
1.In C, when you write to a file, newline characters 'n' must be
explicitly added.
2.The stdio library offers the necessary functions to write to a file:
3.fputc(char, file_pointer): It writes a character to the file pointed
to by file_pointer.
4.fputs(str, file_pointer): It writes a string to the file pointed to by
file_pointer.
5.fprintf(file_pointer, str, variable_lists): It prints a string to the file
pointed to by file_pointer. The string can optionally include
format specifiers and a list of variables variable_lists.