SlideShare a Scribd company logo
1 of 4
Download to read offline
The file c_wiki.txt contains the first section of the Wikipedia page about the C Language. The
file contains 4 paragraphs. Write a C (please not C++) program that reads the file and writes out
each paragraph in a separate file.
c_wiki.txt:
Solution
Please follow the code and comments for description :
CODE :
#include // required header files
#include
#include
int main() { // driver method
FILE *inp_file;
FILE * out_file[4]; // array of file pointers
int lineCount = 0; // local variables
char * readLine = NULL;
char name[FILENAME_MAX] = "c_wiki";
size_t readLen = 0;
ssize_t readSize;
for (int i = 1; i <= 4; i++) { // creating the files
sprintf(name, "c_wiki-%d.txt", i);
out_file[i] = fopen(name, "w");
}
inp_file = fopen("c_wiki.txt", "r"); // read the file
if (inp_file == NULL) { // check for null
exit(EXIT_FAILURE);
}
while ((readSize = getline(&readLine, &readLen, inp_file)) != -1) { // iterate over the data
printf("Retrieved line of length %zu : ", readSize);
if (readSize == 2) {
lineCount++;
}
if (lineCount == 0) { // based on the count write the data to files
fprintf(out_file[1], "%s", readLine);
} else if (lineCount == 1) {
fclose(out_file[1]);
fprintf(out_file[2], "%s", readLine);
} else if (lineCount == 2) {
fclose(out_file[2]);
fprintf(out_file[3], "%s", readLine);
} else if (lineCount == 3) {
fclose(out_file[3]);
fprintf(out_file[4], "%s", readLine);
} else {
fclose(out_file[4]);
}
}
fclose(inp_file); // close the read file
if (readLine) { // empty the line
free(readLine);
}
exit(EXIT_SUCCESS); // exit the code
return 0;
}
OUTPUT :
c_wiki.txt :
In computing, C (pronounced like the letter C) is a general-purpose programming language
initially developed by Dennis Ritchie between 1969 and 1973 at Bell Labs.[4] Its design
provides constructs that map efficiently to typical machine instructions, and therefore it
found lasting use in applications that had formerly been coded in assembly language, most
notably system software like the Unix computer operating system.
C is one of the most widely used programming languages of all time, and there are
very few computer architectures for which a C compiler does not exist.
Many later languages have borrowed directly or indirectly from C, including: C#, D, Go,
Java, JavaScript, Limbo, LPC, Perl, PHP, Python, and Unix's C Shell. The most pervasive
influence on these languages has been syntactical, and they tend to combine the
recognizable expression and statement syntax of C with underlying type systems and data
models that can be radically different. C++ started as a preprocessor for C and is
currently nearly a superset of C.
Before there was an official standard for C, many users and implementors relied on an
informal specification contained in a book by Ritchie and Brian Kernighan; that version is
generally referred to as "K&R" C. In 1989 the American National Standards Institute
published a standard for C (generally called "ANSI C" or "C89"). The next year, the same
specification was approved by the International Organization for Standardization as an
international standard (generally called "C90"). ISO later released an extension to the
internationalization support of the standard in 1995, and a revised standard (known as
"C99") in 1999. The current version of the standard (now known as "C11") was approved in
December of 2011. Adapted from Wikipedia C_(programming_language)
c_wiki-1.txt :
In computing, C (pronounced like the letter C) is a general-purpose programming language
initially developed by Dennis Ritchie between 1969 and 1973 at Bell Labs.[4] Its design
provides constructs that map efficiently to typical machine instructions, and therefore it
found lasting use in applications that had formerly been coded in assembly language, most
notably system software like the Unix computer operating system.
c_wiki-2.txt :
C is one of the most widely used programming languages of all time, and there are
very few computer architectures for which a C compiler does not exist.
c_wiki-3.txt :
Many later languages have borrowed directly or indirectly from C, including: C#, D, Go,
Java, JavaScript, Limbo, LPC, Perl, PHP, Python, and Unix's C Shell. The most pervasive
influence on these languages has been syntactical, and they tend to combine the
recognizable expression and statement syntax of C with underlying type systems and data
models that can be radically different. C++ started as a preprocessor for C and is
currently nearly a superset of C.
c_wiki-4.txt :
Before there was an official standard for C, many users and implementors relied on an
informal specification contained in a book by Ritchie and Brian Kernighan; that version is
generally referred to as "K&R" C. In 1989 the American National Standards Institute
published a standard for C (generally called "ANSI C" or "C89"). The next year, the same
specification was approved by the International Organization for Standardization as an
international standard (generally called "C90"). ISO later released an extension to the
internationalization support of the standard in 1995, and a revised standard (known as
"C99") in 1999. The current version of the standard (now known as "C11") was approved in
December of 2011. Adapted from Wikipedia C_(programming_language)
Hope this is helpful.

More Related Content

Similar to The file c_wiki.txt contains the first section of the Wikipedia page.pdf

Similar to The file c_wiki.txt contains the first section of the Wikipedia page.pdf (20)

Introduction of c programming unit-ii ppt
Introduction of  c programming unit-ii pptIntroduction of  c programming unit-ii ppt
Introduction of c programming unit-ii ppt
 
chapter 1.pptx
chapter 1.pptxchapter 1.pptx
chapter 1.pptx
 
Unit 2 l1
Unit 2 l1Unit 2 l1
Unit 2 l1
 
What is turbo c and how it works
What is turbo c and how it worksWhat is turbo c and how it works
What is turbo c and how it works
 
Learn C Language
Learn C LanguageLearn C Language
Learn C Language
 
C language
C languageC language
C language
 
Fundamentals of programming and problem solving
Fundamentals of programming and problem solvingFundamentals of programming and problem solving
Fundamentals of programming and problem solving
 
CS8251_QB_answers.pdf
CS8251_QB_answers.pdfCS8251_QB_answers.pdf
CS8251_QB_answers.pdf
 
01 c
01 c01 c
01 c
 
C session 1.pptx
C session 1.pptxC session 1.pptx
C session 1.pptx
 
C Fundamental.docx
C Fundamental.docxC Fundamental.docx
C Fundamental.docx
 
Intro to cprogramming
Intro to cprogrammingIntro to cprogramming
Intro to cprogramming
 
Lecture 1 progrmming with C
Lecture 1 progrmming with C Lecture 1 progrmming with C
Lecture 1 progrmming with C
 
Summer training PPT Manasv Singharia.pptx
Summer training PPT Manasv Singharia.pptxSummer training PPT Manasv Singharia.pptx
Summer training PPT Manasv Singharia.pptx
 
C Programming UNIT 1.pptx
C Programming  UNIT 1.pptxC Programming  UNIT 1.pptx
C Programming UNIT 1.pptx
 
Overview of c
Overview of cOverview of c
Overview of c
 
C Programming Language
C Programming LanguageC Programming Language
C Programming Language
 
CS3251-_PIC
CS3251-_PICCS3251-_PIC
CS3251-_PIC
 
C Unit 1 notes PREPARED BY MVB REDDY
C Unit 1 notes PREPARED BY MVB REDDYC Unit 1 notes PREPARED BY MVB REDDY
C Unit 1 notes PREPARED BY MVB REDDY
 
Unit 2 ppt
Unit 2 pptUnit 2 ppt
Unit 2 ppt
 

More from archigallery1298

Explain the DSM is and how it defines a psychological disorder. P.pdf
Explain the DSM is and how it defines a psychological disorder. P.pdfExplain the DSM is and how it defines a psychological disorder. P.pdf
Explain the DSM is and how it defines a psychological disorder. P.pdfarchigallery1298
 
Ethical egoism is a form of..benefit-harm theory. divine Command theo.pdf
Ethical egoism is a form of..benefit-harm theory. divine Command theo.pdfEthical egoism is a form of..benefit-harm theory. divine Command theo.pdf
Ethical egoism is a form of..benefit-harm theory. divine Command theo.pdfarchigallery1298
 
Evolutionary theorists believe the need to belong is at the ________.pdf
Evolutionary theorists believe the need to belong is at the ________.pdfEvolutionary theorists believe the need to belong is at the ________.pdf
Evolutionary theorists believe the need to belong is at the ________.pdfarchigallery1298
 
Describe the differences among dominance, incomplete dominance, codo.pdf
Describe the differences among dominance, incomplete dominance, codo.pdfDescribe the differences among dominance, incomplete dominance, codo.pdf
Describe the differences among dominance, incomplete dominance, codo.pdfarchigallery1298
 
Describe 3 ideas or techniques that describe how to make a web page .pdf
Describe 3 ideas or techniques that describe how to make a web page .pdfDescribe 3 ideas or techniques that describe how to make a web page .pdf
Describe 3 ideas or techniques that describe how to make a web page .pdfarchigallery1298
 
Consider this C++ BankAccount class with the following public member.pdf
Consider this C++ BankAccount class with the following public member.pdfConsider this C++ BankAccount class with the following public member.pdf
Consider this C++ BankAccount class with the following public member.pdfarchigallery1298
 
Compared with the interior, which of the following changes is usually.pdf
Compared with the interior, which of the following changes is usually.pdfCompared with the interior, which of the following changes is usually.pdf
Compared with the interior, which of the following changes is usually.pdfarchigallery1298
 
Both influenza virus and (IFV), and Measles Virus (MV) are enveloped.pdf
Both influenza virus and (IFV), and Measles Virus (MV) are enveloped.pdfBoth influenza virus and (IFV), and Measles Virus (MV) are enveloped.pdf
Both influenza virus and (IFV), and Measles Virus (MV) are enveloped.pdfarchigallery1298
 
Are the structures present in the organisms or not Amswer Yes or No.pdf
Are the structures present in the organisms or not Amswer Yes or No.pdfAre the structures present in the organisms or not Amswer Yes or No.pdf
Are the structures present in the organisms or not Amswer Yes or No.pdfarchigallery1298
 
3. When and what was the first operating system which integrated sec.pdf
3. When and what was the first operating system which integrated sec.pdf3. When and what was the first operating system which integrated sec.pdf
3. When and what was the first operating system which integrated sec.pdfarchigallery1298
 
Write an SQL statement to answer the question.Primary keys are( BO.pdf
Write an SQL statement to answer the question.Primary keys are( BO.pdfWrite an SQL statement to answer the question.Primary keys are( BO.pdf
Write an SQL statement to answer the question.Primary keys are( BO.pdfarchigallery1298
 
You are running the Windows installation setup for Windows Vista on .pdf
You are running the Windows installation setup for Windows Vista on .pdfYou are running the Windows installation setup for Windows Vista on .pdf
You are running the Windows installation setup for Windows Vista on .pdfarchigallery1298
 
1.Based on current fossil evidenceSelect onea. whales were lik.pdf
1.Based on current fossil evidenceSelect onea. whales were lik.pdf1.Based on current fossil evidenceSelect onea. whales were lik.pdf
1.Based on current fossil evidenceSelect onea. whales were lik.pdfarchigallery1298
 
Which of the following is NOT a characteristic of the normal probabi.pdf
Which of the following is NOT a characteristic of the normal probabi.pdfWhich of the following is NOT a characteristic of the normal probabi.pdf
Which of the following is NOT a characteristic of the normal probabi.pdfarchigallery1298
 
Which addresses do Physical layer devices—such as repeaters and hubs.pdf
Which addresses do Physical layer devices—such as repeaters and hubs.pdfWhich addresses do Physical layer devices—such as repeaters and hubs.pdf
Which addresses do Physical layer devices—such as repeaters and hubs.pdfarchigallery1298
 
What structure of the femur fits in the acetabular fossa Which Is s.pdf
What structure of the femur fits in the acetabular fossa  Which Is s.pdfWhat structure of the femur fits in the acetabular fossa  Which Is s.pdf
What structure of the femur fits in the acetabular fossa Which Is s.pdfarchigallery1298
 
What is HIPAA Why was it passed What arc the potential benefits to .pdf
What is HIPAA Why was it passed What arc the potential benefits to .pdfWhat is HIPAA Why was it passed What arc the potential benefits to .pdf
What is HIPAA Why was it passed What arc the potential benefits to .pdfarchigallery1298
 
what are the similarties and difference between bacterial growth .pdf
what are the similarties and difference between bacterial growth .pdfwhat are the similarties and difference between bacterial growth .pdf
what are the similarties and difference between bacterial growth .pdfarchigallery1298
 
What are some examples of analog data What about digital dataS.pdf
What are some examples of analog data What about digital dataS.pdfWhat are some examples of analog data What about digital dataS.pdf
What are some examples of analog data What about digital dataS.pdfarchigallery1298
 
This problem is about Lebesgue Integration problem. Thank you fo.pdf
This problem is about Lebesgue Integration problem. Thank you fo.pdfThis problem is about Lebesgue Integration problem. Thank you fo.pdf
This problem is about Lebesgue Integration problem. Thank you fo.pdfarchigallery1298
 

More from archigallery1298 (20)

Explain the DSM is and how it defines a psychological disorder. P.pdf
Explain the DSM is and how it defines a psychological disorder. P.pdfExplain the DSM is and how it defines a psychological disorder. P.pdf
Explain the DSM is and how it defines a psychological disorder. P.pdf
 
Ethical egoism is a form of..benefit-harm theory. divine Command theo.pdf
Ethical egoism is a form of..benefit-harm theory. divine Command theo.pdfEthical egoism is a form of..benefit-harm theory. divine Command theo.pdf
Ethical egoism is a form of..benefit-harm theory. divine Command theo.pdf
 
Evolutionary theorists believe the need to belong is at the ________.pdf
Evolutionary theorists believe the need to belong is at the ________.pdfEvolutionary theorists believe the need to belong is at the ________.pdf
Evolutionary theorists believe the need to belong is at the ________.pdf
 
Describe the differences among dominance, incomplete dominance, codo.pdf
Describe the differences among dominance, incomplete dominance, codo.pdfDescribe the differences among dominance, incomplete dominance, codo.pdf
Describe the differences among dominance, incomplete dominance, codo.pdf
 
Describe 3 ideas or techniques that describe how to make a web page .pdf
Describe 3 ideas or techniques that describe how to make a web page .pdfDescribe 3 ideas or techniques that describe how to make a web page .pdf
Describe 3 ideas or techniques that describe how to make a web page .pdf
 
Consider this C++ BankAccount class with the following public member.pdf
Consider this C++ BankAccount class with the following public member.pdfConsider this C++ BankAccount class with the following public member.pdf
Consider this C++ BankAccount class with the following public member.pdf
 
Compared with the interior, which of the following changes is usually.pdf
Compared with the interior, which of the following changes is usually.pdfCompared with the interior, which of the following changes is usually.pdf
Compared with the interior, which of the following changes is usually.pdf
 
Both influenza virus and (IFV), and Measles Virus (MV) are enveloped.pdf
Both influenza virus and (IFV), and Measles Virus (MV) are enveloped.pdfBoth influenza virus and (IFV), and Measles Virus (MV) are enveloped.pdf
Both influenza virus and (IFV), and Measles Virus (MV) are enveloped.pdf
 
Are the structures present in the organisms or not Amswer Yes or No.pdf
Are the structures present in the organisms or not Amswer Yes or No.pdfAre the structures present in the organisms or not Amswer Yes or No.pdf
Are the structures present in the organisms or not Amswer Yes or No.pdf
 
3. When and what was the first operating system which integrated sec.pdf
3. When and what was the first operating system which integrated sec.pdf3. When and what was the first operating system which integrated sec.pdf
3. When and what was the first operating system which integrated sec.pdf
 
Write an SQL statement to answer the question.Primary keys are( BO.pdf
Write an SQL statement to answer the question.Primary keys are( BO.pdfWrite an SQL statement to answer the question.Primary keys are( BO.pdf
Write an SQL statement to answer the question.Primary keys are( BO.pdf
 
You are running the Windows installation setup for Windows Vista on .pdf
You are running the Windows installation setup for Windows Vista on .pdfYou are running the Windows installation setup for Windows Vista on .pdf
You are running the Windows installation setup for Windows Vista on .pdf
 
1.Based on current fossil evidenceSelect onea. whales were lik.pdf
1.Based on current fossil evidenceSelect onea. whales were lik.pdf1.Based on current fossil evidenceSelect onea. whales were lik.pdf
1.Based on current fossil evidenceSelect onea. whales were lik.pdf
 
Which of the following is NOT a characteristic of the normal probabi.pdf
Which of the following is NOT a characteristic of the normal probabi.pdfWhich of the following is NOT a characteristic of the normal probabi.pdf
Which of the following is NOT a characteristic of the normal probabi.pdf
 
Which addresses do Physical layer devices—such as repeaters and hubs.pdf
Which addresses do Physical layer devices—such as repeaters and hubs.pdfWhich addresses do Physical layer devices—such as repeaters and hubs.pdf
Which addresses do Physical layer devices—such as repeaters and hubs.pdf
 
What structure of the femur fits in the acetabular fossa Which Is s.pdf
What structure of the femur fits in the acetabular fossa  Which Is s.pdfWhat structure of the femur fits in the acetabular fossa  Which Is s.pdf
What structure of the femur fits in the acetabular fossa Which Is s.pdf
 
What is HIPAA Why was it passed What arc the potential benefits to .pdf
What is HIPAA Why was it passed What arc the potential benefits to .pdfWhat is HIPAA Why was it passed What arc the potential benefits to .pdf
What is HIPAA Why was it passed What arc the potential benefits to .pdf
 
what are the similarties and difference between bacterial growth .pdf
what are the similarties and difference between bacterial growth .pdfwhat are the similarties and difference between bacterial growth .pdf
what are the similarties and difference between bacterial growth .pdf
 
What are some examples of analog data What about digital dataS.pdf
What are some examples of analog data What about digital dataS.pdfWhat are some examples of analog data What about digital dataS.pdf
What are some examples of analog data What about digital dataS.pdf
 
This problem is about Lebesgue Integration problem. Thank you fo.pdf
This problem is about Lebesgue Integration problem. Thank you fo.pdfThis problem is about Lebesgue Integration problem. Thank you fo.pdf
This problem is about Lebesgue Integration problem. Thank you fo.pdf
 

Recently uploaded

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 

Recently uploaded (20)

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 

The file c_wiki.txt contains the first section of the Wikipedia page.pdf

  • 1. The file c_wiki.txt contains the first section of the Wikipedia page about the C Language. The file contains 4 paragraphs. Write a C (please not C++) program that reads the file and writes out each paragraph in a separate file. c_wiki.txt: Solution Please follow the code and comments for description : CODE : #include // required header files #include #include int main() { // driver method FILE *inp_file; FILE * out_file[4]; // array of file pointers int lineCount = 0; // local variables char * readLine = NULL; char name[FILENAME_MAX] = "c_wiki"; size_t readLen = 0; ssize_t readSize; for (int i = 1; i <= 4; i++) { // creating the files sprintf(name, "c_wiki-%d.txt", i); out_file[i] = fopen(name, "w"); } inp_file = fopen("c_wiki.txt", "r"); // read the file if (inp_file == NULL) { // check for null exit(EXIT_FAILURE); } while ((readSize = getline(&readLine, &readLen, inp_file)) != -1) { // iterate over the data printf("Retrieved line of length %zu : ", readSize); if (readSize == 2) { lineCount++; } if (lineCount == 0) { // based on the count write the data to files fprintf(out_file[1], "%s", readLine);
  • 2. } else if (lineCount == 1) { fclose(out_file[1]); fprintf(out_file[2], "%s", readLine); } else if (lineCount == 2) { fclose(out_file[2]); fprintf(out_file[3], "%s", readLine); } else if (lineCount == 3) { fclose(out_file[3]); fprintf(out_file[4], "%s", readLine); } else { fclose(out_file[4]); } } fclose(inp_file); // close the read file if (readLine) { // empty the line free(readLine); } exit(EXIT_SUCCESS); // exit the code return 0; } OUTPUT : c_wiki.txt : In computing, C (pronounced like the letter C) is a general-purpose programming language initially developed by Dennis Ritchie between 1969 and 1973 at Bell Labs.[4] Its design provides constructs that map efficiently to typical machine instructions, and therefore it found lasting use in applications that had formerly been coded in assembly language, most notably system software like the Unix computer operating system. C is one of the most widely used programming languages of all time, and there are very few computer architectures for which a C compiler does not exist. Many later languages have borrowed directly or indirectly from C, including: C#, D, Go, Java, JavaScript, Limbo, LPC, Perl, PHP, Python, and Unix's C Shell. The most pervasive influence on these languages has been syntactical, and they tend to combine the recognizable expression and statement syntax of C with underlying type systems and data models that can be radically different. C++ started as a preprocessor for C and is
  • 3. currently nearly a superset of C. Before there was an official standard for C, many users and implementors relied on an informal specification contained in a book by Ritchie and Brian Kernighan; that version is generally referred to as "K&R" C. In 1989 the American National Standards Institute published a standard for C (generally called "ANSI C" or "C89"). The next year, the same specification was approved by the International Organization for Standardization as an international standard (generally called "C90"). ISO later released an extension to the internationalization support of the standard in 1995, and a revised standard (known as "C99") in 1999. The current version of the standard (now known as "C11") was approved in December of 2011. Adapted from Wikipedia C_(programming_language) c_wiki-1.txt : In computing, C (pronounced like the letter C) is a general-purpose programming language initially developed by Dennis Ritchie between 1969 and 1973 at Bell Labs.[4] Its design provides constructs that map efficiently to typical machine instructions, and therefore it found lasting use in applications that had formerly been coded in assembly language, most notably system software like the Unix computer operating system. c_wiki-2.txt : C is one of the most widely used programming languages of all time, and there are very few computer architectures for which a C compiler does not exist. c_wiki-3.txt : Many later languages have borrowed directly or indirectly from C, including: C#, D, Go, Java, JavaScript, Limbo, LPC, Perl, PHP, Python, and Unix's C Shell. The most pervasive influence on these languages has been syntactical, and they tend to combine the recognizable expression and statement syntax of C with underlying type systems and data models that can be radically different. C++ started as a preprocessor for C and is currently nearly a superset of C. c_wiki-4.txt : Before there was an official standard for C, many users and implementors relied on an informal specification contained in a book by Ritchie and Brian Kernighan; that version is generally referred to as "K&R" C. In 1989 the American National Standards Institute published a standard for C (generally called "ANSI C" or "C89"). The next year, the same specification was approved by the International Organization for Standardization as an international standard (generally called "C90"). ISO later released an extension to the internationalization support of the standard in 1995, and a revised standard (known as "C99") in 1999. The current version of the standard (now known as "C11") was approved in
  • 4. December of 2011. Adapted from Wikipedia C_(programming_language) Hope this is helpful.