SlideShare uma empresa Scribd logo
1 de 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;
}

Mais conteúdo relacionado

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

Semelhante a 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
 

Mais 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
 

Mais 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
 

Último

Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
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
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
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
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
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
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
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
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
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
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 

Último (20)

Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
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"
 
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
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
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
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
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
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
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
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
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
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 

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; }