SlideShare une entreprise Scribd logo
1  sur  3
Solution in C please.
Write a program that processes a data file of names in which each name is on a separate line of at
most 80 characters. Here are two sample names:
Hartman-Montgomery,
Jane R. Doe, J. D.
On each line the surname is followed by a comma and a space. Next comes the first name or
initial, then a space and the middle initial. Your program should scan the names into three
arrays_surname, first, and middle_init. If the surname is longer than 15 characters, store only the
first 15. Similarly, limit the first name to ten characters. Do not store periods in the first and
middle_init arrays. Write the array’s contents to a file, aligning the contents of each column:
Hartman-Montgomery, Jane R
Doe J D
Solution
Ans;
#include<stdio.h>
int main()
{
freopen("in.txt" , "r" , stdin);
freopen("out.txt" , "w" , stdout);
int co = 0 , line = 0;
char c , inp[100] = {'0'};
while(gets(inp))
{
char surname[16] = {'0'}, first_name[11] = {'0'}, last_name[11] = {'0'};
int sidx = 0 , fidx = 0 , lidx = 0;
co++;
int l = strlen(inp) , i = 0 , j = 0, k = 0 , fflag = 0 , sflag = 0;
for(i=0;i<l;i++) {
if(inp[i] == ',') break;
if(sidx >= 15) sflag = 1;
if(sflag == 0) {
surname[sidx] = inp[i];
sidx++;
}
}
surname[sidx] = '0';
i++; // Increment to avoid space
for(j=i+1;j<l;j++) {
if(inp[j] == ' ') break;
if(fidx >= 10) fflag = 1;
if(inp[j] != '.' && fflag == 0) {
first_name[fidx] = inp[j];
fidx++;
}
}
first_name[fidx] = '0';
for(k=j+1;k<l;k++) {
if(lidx >= 10) break;
last_name[lidx] = inp[k];
lidx++;
}
last_name[lidx] = '0';
printf("%s %s %s ",surname , first_name , last_name);
}
return 0;
}

Contenu connexe

Similaire à Solution in C please- Write a program that processes a data file of na.docx

Similaire à Solution in C please- Write a program that processes a data file of na.docx (10)

Huffman
HuffmanHuffman
Huffman
 
Huffman
HuffmanHuffman
Huffman
 
String in c
String in cString in c
String in c
 
Python
PythonPython
Python
 
Tut1
Tut1Tut1
Tut1
 
C programming session 04
C programming session 04C programming session 04
C programming session 04
 
Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional array
 
C Language Lecture 13
C Language Lecture 13C Language Lecture 13
C Language Lecture 13
 
Lecture 15_Strings and Dynamic Memory Allocation.pptx
Lecture 15_Strings and  Dynamic Memory Allocation.pptxLecture 15_Strings and  Dynamic Memory Allocation.pptx
Lecture 15_Strings and Dynamic Memory Allocation.pptx
 
C Programming Unit-3
C Programming Unit-3C Programming Unit-3
C Programming Unit-3
 

Plus de rennaknapp

Language is C++ I'm having trouble making my code meet these requireme.docx
Language is C++ I'm having trouble making my code meet these requireme.docxLanguage is C++ I'm having trouble making my code meet these requireme.docx
Language is C++ I'm having trouble making my code meet these requireme.docxrennaknapp
 
Land use changes and changing climatic conditions caused by human acti.docx
Land use changes and changing climatic conditions caused by human acti.docxLand use changes and changing climatic conditions caused by human acti.docx
Land use changes and changing climatic conditions caused by human acti.docxrennaknapp
 
Kimberly had to come up With a whictue data collection and analysis pr.docx
Kimberly had to come up With a whictue data collection and analysis pr.docxKimberly had to come up With a whictue data collection and analysis pr.docx
Kimberly had to come up With a whictue data collection and analysis pr.docxrennaknapp
 
Korb et al- (2000) obtained blood samples extracted fom patients infec.docx
Korb et al- (2000) obtained blood samples extracted fom patients infec.docxKorb et al- (2000) obtained blood samples extracted fom patients infec.docx
Korb et al- (2000) obtained blood samples extracted fom patients infec.docxrennaknapp
 
keep it simple pls Create a project named labExamCCCS221 containing fo.docx
keep it simple pls Create a project named labExamCCCS221 containing fo.docxkeep it simple pls Create a project named labExamCCCS221 containing fo.docx
keep it simple pls Create a project named labExamCCCS221 containing fo.docxrennaknapp
 
l Question 4 1 pts Gatekeeper tumor suppressor genes--- Encode prote.docx
l   Question 4 1 pts Gatekeeper tumor suppressor genes--- Encode prote.docxl   Question 4 1 pts Gatekeeper tumor suppressor genes--- Encode prote.docx
l Question 4 1 pts Gatekeeper tumor suppressor genes--- Encode prote.docxrennaknapp
 
L0-4 During 2022- Jenny- age 14- lives in a household with her father-.docx
L0-4 During 2022- Jenny- age 14- lives in a household with her father-.docxL0-4 During 2022- Jenny- age 14- lives in a household with her father-.docx
L0-4 During 2022- Jenny- age 14- lives in a household with her father-.docxrennaknapp
 
L0-7 In 2022- Jack- age 12 - has interest income of $4-900 on funds he.docx
L0-7 In 2022- Jack- age 12 - has interest income of $4-900 on funds he.docxL0-7 In 2022- Jack- age 12 - has interest income of $4-900 on funds he.docx
L0-7 In 2022- Jack- age 12 - has interest income of $4-900 on funds he.docxrennaknapp
 
Kyle is a student with an emotional behavioral disorder- He has also b.docx
Kyle is a student with an emotional behavioral disorder- He has also b.docxKyle is a student with an emotional behavioral disorder- He has also b.docx
Kyle is a student with an emotional behavioral disorder- He has also b.docxrennaknapp
 
Json File - { -student_id-- 101- -first_name-- -James--.docx
Json File -   {     -student_id-- 101-     -first_name-- -James--.docxJson File -   {     -student_id-- 101-     -first_name-- -James--.docx
Json File - { -student_id-- 101- -first_name-- -James--.docxrennaknapp
 
Make a concept map that shows the hierarchical relationship between th.docx
Make a concept map that shows the hierarchical relationship between th.docxMake a concept map that shows the hierarchical relationship between th.docx
Make a concept map that shows the hierarchical relationship between th.docxrennaknapp
 
Jordan and Alyssa are saving for their daughter Taylor's college educa.docx
Jordan and Alyssa are saving for their daughter Taylor's college educa.docxJordan and Alyssa are saving for their daughter Taylor's college educa.docx
Jordan and Alyssa are saving for their daughter Taylor's college educa.docxrennaknapp
 
John receives $3-400 from an investment at the beginning of every half.docx
John receives $3-400 from an investment at the beginning of every half.docxJohn receives $3-400 from an investment at the beginning of every half.docx
John receives $3-400 from an investment at the beginning of every half.docxrennaknapp
 
Many documents use a specific format for a person's name- Write a prog.docx
Many documents use a specific format for a person's name- Write a prog.docxMany documents use a specific format for a person's name- Write a prog.docx
Many documents use a specific format for a person's name- Write a prog.docxrennaknapp
 
Many crimes- like embezzlement- have definite trends- The demographic.docx
Many crimes- like embezzlement- have definite trends- The demographic.docxMany crimes- like embezzlement- have definite trends- The demographic.docx
Many crimes- like embezzlement- have definite trends- The demographic.docxrennaknapp
 
Management The consequences of unresolved conflict often have devastat.docx
Management The consequences of unresolved conflict often have devastat.docxManagement The consequences of unresolved conflict often have devastat.docx
Management The consequences of unresolved conflict often have devastat.docxrennaknapp
 
Make a star field as in Star Trek (the original series)- like MS's.docx
Make a star field as in Star Trek (the original series)- like  MS's.docxMake a star field as in Star Trek (the original series)- like  MS's.docx
Make a star field as in Star Trek (the original series)- like MS's.docxrennaknapp
 
MAKE a CONCEPT MAP illustrating how glycolysis- the Krebs-Citric acid.docx
MAKE a CONCEPT MAP illustrating how glycolysis- the Krebs-Citric acid.docxMAKE a CONCEPT MAP illustrating how glycolysis- the Krebs-Citric acid.docx
MAKE a CONCEPT MAP illustrating how glycolysis- the Krebs-Citric acid.docxrennaknapp
 
John plans to add a new operation Peek to the stackADT- This new opera.docx
John plans to add a new operation Peek to the stackADT- This new opera.docxJohn plans to add a new operation Peek to the stackADT- This new opera.docx
John plans to add a new operation Peek to the stackADT- This new opera.docxrennaknapp
 
John is a part of a team that has been gathered temporarily to develop.docx
John is a part of a team that has been gathered temporarily to develop.docxJohn is a part of a team that has been gathered temporarily to develop.docx
John is a part of a team that has been gathered temporarily to develop.docxrennaknapp
 

Plus de rennaknapp (20)

Language is C++ I'm having trouble making my code meet these requireme.docx
Language is C++ I'm having trouble making my code meet these requireme.docxLanguage is C++ I'm having trouble making my code meet these requireme.docx
Language is C++ I'm having trouble making my code meet these requireme.docx
 
Land use changes and changing climatic conditions caused by human acti.docx
Land use changes and changing climatic conditions caused by human acti.docxLand use changes and changing climatic conditions caused by human acti.docx
Land use changes and changing climatic conditions caused by human acti.docx
 
Kimberly had to come up With a whictue data collection and analysis pr.docx
Kimberly had to come up With a whictue data collection and analysis pr.docxKimberly had to come up With a whictue data collection and analysis pr.docx
Kimberly had to come up With a whictue data collection and analysis pr.docx
 
Korb et al- (2000) obtained blood samples extracted fom patients infec.docx
Korb et al- (2000) obtained blood samples extracted fom patients infec.docxKorb et al- (2000) obtained blood samples extracted fom patients infec.docx
Korb et al- (2000) obtained blood samples extracted fom patients infec.docx
 
keep it simple pls Create a project named labExamCCCS221 containing fo.docx
keep it simple pls Create a project named labExamCCCS221 containing fo.docxkeep it simple pls Create a project named labExamCCCS221 containing fo.docx
keep it simple pls Create a project named labExamCCCS221 containing fo.docx
 
l Question 4 1 pts Gatekeeper tumor suppressor genes--- Encode prote.docx
l   Question 4 1 pts Gatekeeper tumor suppressor genes--- Encode prote.docxl   Question 4 1 pts Gatekeeper tumor suppressor genes--- Encode prote.docx
l Question 4 1 pts Gatekeeper tumor suppressor genes--- Encode prote.docx
 
L0-4 During 2022- Jenny- age 14- lives in a household with her father-.docx
L0-4 During 2022- Jenny- age 14- lives in a household with her father-.docxL0-4 During 2022- Jenny- age 14- lives in a household with her father-.docx
L0-4 During 2022- Jenny- age 14- lives in a household with her father-.docx
 
L0-7 In 2022- Jack- age 12 - has interest income of $4-900 on funds he.docx
L0-7 In 2022- Jack- age 12 - has interest income of $4-900 on funds he.docxL0-7 In 2022- Jack- age 12 - has interest income of $4-900 on funds he.docx
L0-7 In 2022- Jack- age 12 - has interest income of $4-900 on funds he.docx
 
Kyle is a student with an emotional behavioral disorder- He has also b.docx
Kyle is a student with an emotional behavioral disorder- He has also b.docxKyle is a student with an emotional behavioral disorder- He has also b.docx
Kyle is a student with an emotional behavioral disorder- He has also b.docx
 
Json File - { -student_id-- 101- -first_name-- -James--.docx
Json File -   {     -student_id-- 101-     -first_name-- -James--.docxJson File -   {     -student_id-- 101-     -first_name-- -James--.docx
Json File - { -student_id-- 101- -first_name-- -James--.docx
 
Make a concept map that shows the hierarchical relationship between th.docx
Make a concept map that shows the hierarchical relationship between th.docxMake a concept map that shows the hierarchical relationship between th.docx
Make a concept map that shows the hierarchical relationship between th.docx
 
Jordan and Alyssa are saving for their daughter Taylor's college educa.docx
Jordan and Alyssa are saving for their daughter Taylor's college educa.docxJordan and Alyssa are saving for their daughter Taylor's college educa.docx
Jordan and Alyssa are saving for their daughter Taylor's college educa.docx
 
John receives $3-400 from an investment at the beginning of every half.docx
John receives $3-400 from an investment at the beginning of every half.docxJohn receives $3-400 from an investment at the beginning of every half.docx
John receives $3-400 from an investment at the beginning of every half.docx
 
Many documents use a specific format for a person's name- Write a prog.docx
Many documents use a specific format for a person's name- Write a prog.docxMany documents use a specific format for a person's name- Write a prog.docx
Many documents use a specific format for a person's name- Write a prog.docx
 
Many crimes- like embezzlement- have definite trends- The demographic.docx
Many crimes- like embezzlement- have definite trends- The demographic.docxMany crimes- like embezzlement- have definite trends- The demographic.docx
Many crimes- like embezzlement- have definite trends- The demographic.docx
 
Management The consequences of unresolved conflict often have devastat.docx
Management The consequences of unresolved conflict often have devastat.docxManagement The consequences of unresolved conflict often have devastat.docx
Management The consequences of unresolved conflict often have devastat.docx
 
Make a star field as in Star Trek (the original series)- like MS's.docx
Make a star field as in Star Trek (the original series)- like  MS's.docxMake a star field as in Star Trek (the original series)- like  MS's.docx
Make a star field as in Star Trek (the original series)- like MS's.docx
 
MAKE a CONCEPT MAP illustrating how glycolysis- the Krebs-Citric acid.docx
MAKE a CONCEPT MAP illustrating how glycolysis- the Krebs-Citric acid.docxMAKE a CONCEPT MAP illustrating how glycolysis- the Krebs-Citric acid.docx
MAKE a CONCEPT MAP illustrating how glycolysis- the Krebs-Citric acid.docx
 
John plans to add a new operation Peek to the stackADT- This new opera.docx
John plans to add a new operation Peek to the stackADT- This new opera.docxJohn plans to add a new operation Peek to the stackADT- This new opera.docx
John plans to add a new operation Peek to the stackADT- This new opera.docx
 
John is a part of a team that has been gathered temporarily to develop.docx
John is a part of a team that has been gathered temporarily to develop.docxJohn is a part of a team that has been gathered temporarily to develop.docx
John is a part of a team that has been gathered temporarily to develop.docx
 

Dernier

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
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
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
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
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
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
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
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 

Dernier (20)

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...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
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
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).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
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
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
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 

Solution in C please- Write a program that processes a data file of na.docx

  • 1. Solution in C please. Write a program that processes a data file of names in which each name is on a separate line of at most 80 characters. Here are two sample names: Hartman-Montgomery, Jane R. Doe, J. D. On each line the surname is followed by a comma and a space. Next comes the first name or initial, then a space and the middle initial. Your program should scan the names into three arrays_surname, first, and middle_init. If the surname is longer than 15 characters, store only the first 15. Similarly, limit the first name to ten characters. Do not store periods in the first and middle_init arrays. Write the array’s contents to a file, aligning the contents of each column: Hartman-Montgomery, Jane R Doe J D Solution Ans; #include<stdio.h> int main() { freopen("in.txt" , "r" , stdin); freopen("out.txt" , "w" , stdout); int co = 0 , line = 0; char c , inp[100] = {'0'};
  • 2. while(gets(inp)) { char surname[16] = {'0'}, first_name[11] = {'0'}, last_name[11] = {'0'}; int sidx = 0 , fidx = 0 , lidx = 0; co++; int l = strlen(inp) , i = 0 , j = 0, k = 0 , fflag = 0 , sflag = 0; for(i=0;i<l;i++) { if(inp[i] == ',') break; if(sidx >= 15) sflag = 1; if(sflag == 0) { surname[sidx] = inp[i]; sidx++; } } surname[sidx] = '0'; i++; // Increment to avoid space for(j=i+1;j<l;j++) { if(inp[j] == ' ') break; if(fidx >= 10) fflag = 1; if(inp[j] != '.' && fflag == 0) { first_name[fidx] = inp[j]; fidx++; }
  • 3. } first_name[fidx] = '0'; for(k=j+1;k<l;k++) { if(lidx >= 10) break; last_name[lidx] = inp[k]; lidx++; } last_name[lidx] = '0'; printf("%s %s %s ",surname , first_name , last_name); } return 0; }