SlideShare a Scribd company logo
1 of 2
Download to read offline
include getopt in this code with the usage % doublesort [-d] [-o output_file_name] input_file_name:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
typedef struct node {
char* data;
struct node* prev;
struct node* next;
} Node;
Node* create_node(char* data) {
Node* new_node = malloc(sizeof(Node));
new_node->data = malloc(strlen(data) + 1);
strcpy(new_node->data, data);
new_node->prev = NULL;
new_node->next = NULL;
return new_node;
}
void insert_node(Node** head, Node* new_node) {
if (*head == NULL) {
*head = new_node;
return;
}
Node* current_node = *head;
while (current_node->next != NULL && strcmp(new_node->data, current_node->data) > 0) {
current_node = current_node->next;
}
if (current_node->next == NULL && strcmp(new_node->data, current_node->data) > 0) {
current_node->next = new_node;
new_node->prev = current_node;
return;
}
Node* prev_node = current_node->prev;
if (prev_node == NULL) {
*head = new_node;
} else {
prev_node->next = new_node;
}
new_node->prev = prev_node;
new_node->next = current_node;
current_node->prev = new_node;
}
void print_list(Node* head, FILE* output_file) {
while (head != NULL) {
fprintf(output_file, "%sn", head->data);
head = head->next;
}
}
void convert_to_lowercase(char* string) {
for (int i = 0; string[i]; i++) {
string[i] = tolower(string[i]);
}
}
int main(int argc, char* argv[]) {
if (argc != 2) {
printf("Usage: %s input_filen", argv[0]);
return 1;
}
FILE* input_file = fopen(argv[1], "r");
if (input_file == NULL) {
printf("Could not open file %sn", argv[1]);
return 1;
}
Node* head = NULL;
char buffer[100];
while (fgets(buffer, sizeof(buffer), input_file)) {
char* token = strtok(buffer, " tn");
while (token != NULL) {
convert_to_lowercase(token);
Node* new_node = create_node(token);
insert_node(&head, new_node);
token = strtok(NULL, " tn");
}
}
fclose(input_file);
print_list(head, stdout);
return 0;
}

More Related Content

Similar to include getopt in this code with the usage doublesort d.pdf

C code on linked list #include stdio.h #include stdlib.h.pdf
 C code on linked list #include stdio.h #include stdlib.h.pdf C code on linked list #include stdio.h #include stdlib.h.pdf
C code on linked list #include stdio.h #include stdlib.h.pdfdeepua8
 
computer notes - Data Structures - 3
computer notes - Data Structures - 3computer notes - Data Structures - 3
computer notes - Data Structures - 3ecomputernotes
 
C program to insert a node in doubly linked list
C program to insert a node in doubly linked listC program to insert a node in doubly linked list
C program to insert a node in doubly linked listSourav Gayen
 
Rewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdfRewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdfalphaagenciesindia
 
This code currently works. Run it and get a screen shot of its ou.docx
 This code currently works. Run it and get a screen shot of its ou.docx This code currently works. Run it and get a screen shot of its ou.docx
This code currently works. Run it and get a screen shot of its ou.docxKomlin1
 
pleaase I want manual solution forData Structures and Algorithm An.pdf
pleaase I want manual solution forData Structures and Algorithm An.pdfpleaase I want manual solution forData Structures and Algorithm An.pdf
pleaase I want manual solution forData Structures and Algorithm An.pdfwasemanivytreenrco51
 
How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js ModuleFred Chien
 
Implement of c &amp; its coding programming by sarmad baloch
Implement of c &amp; its coding  programming by sarmad balochImplement of c &amp; its coding  programming by sarmad baloch
Implement of c &amp; its coding programming by sarmad balochSarmad Baloch
 
I want help in the following C++ programming task. Please do coding .pdf
I want help in the following C++ programming task. Please do coding .pdfI want help in the following C++ programming task. Please do coding .pdf
I want help in the following C++ programming task. Please do coding .pdfbermanbeancolungak45
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYMalikireddy Bramhananda Reddy
 
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdfAssignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdffortmdu
 
In C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdfIn C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdffantoosh1
 
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdfTHE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdffathimahardwareelect
 
#includestdio.h#includestring.h#includestdlib.h#define M.pdf
#includestdio.h#includestring.h#includestdlib.h#define M.pdf#includestdio.h#includestring.h#includestdlib.h#define M.pdf
#includestdio.h#includestring.h#includestdlib.h#define M.pdfANJALIENTERPRISES1
 
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdfC++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdfaassecuritysystem
 
reverse the linked list (2-4-8-10) by- stack- iteration- recursion- U.docx
reverse the linked list (2-4-8-10) by- stack- iteration- recursion-  U.docxreverse the linked list (2-4-8-10) by- stack- iteration- recursion-  U.docx
reverse the linked list (2-4-8-10) by- stack- iteration- recursion- U.docxacarolyn
 
C++Write a method Node Nodereverse() which reverses a list..pdf
C++Write a method Node Nodereverse() which reverses a list..pdfC++Write a method Node Nodereverse() which reverses a list..pdf
C++Write a method Node Nodereverse() which reverses a list..pdfarjunenterprises1978
 
Please write in C++ and should be able to compile and debug.Thank yo.pdf
Please write in C++ and should be able to compile and debug.Thank yo.pdfPlease write in C++ and should be able to compile and debug.Thank yo.pdf
Please write in C++ and should be able to compile and debug.Thank yo.pdfajaycosmeticslg
 

Similar to include getopt in this code with the usage doublesort d.pdf (20)

C code on linked list #include stdio.h #include stdlib.h.pdf
 C code on linked list #include stdio.h #include stdlib.h.pdf C code on linked list #include stdio.h #include stdlib.h.pdf
C code on linked list #include stdio.h #include stdlib.h.pdf
 
computer notes - Data Structures - 3
computer notes - Data Structures - 3computer notes - Data Structures - 3
computer notes - Data Structures - 3
 
C program to insert a node in doubly linked list
C program to insert a node in doubly linked listC program to insert a node in doubly linked list
C program to insert a node in doubly linked list
 
Rewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdfRewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdf
 
DS Code (CWH).docx
DS Code (CWH).docxDS Code (CWH).docx
DS Code (CWH).docx
 
This code currently works. Run it and get a screen shot of its ou.docx
 This code currently works. Run it and get a screen shot of its ou.docx This code currently works. Run it and get a screen shot of its ou.docx
This code currently works. Run it and get a screen shot of its ou.docx
 
pleaase I want manual solution forData Structures and Algorithm An.pdf
pleaase I want manual solution forData Structures and Algorithm An.pdfpleaase I want manual solution forData Structures and Algorithm An.pdf
pleaase I want manual solution forData Structures and Algorithm An.pdf
 
How to Write Node.js Module
How to Write Node.js ModuleHow to Write Node.js Module
How to Write Node.js Module
 
Implement of c &amp; its coding programming by sarmad baloch
Implement of c &amp; its coding  programming by sarmad balochImplement of c &amp; its coding  programming by sarmad baloch
Implement of c &amp; its coding programming by sarmad baloch
 
I want help in the following C++ programming task. Please do coding .pdf
I want help in the following C++ programming task. Please do coding .pdfI want help in the following C++ programming task. Please do coding .pdf
I want help in the following C++ programming task. Please do coding .pdf
 
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDYDATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
 
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdfAssignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
 
In C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdfIn C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdf
 
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdfTHE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
 
#includestdio.h#includestring.h#includestdlib.h#define M.pdf
#includestdio.h#includestring.h#includestdlib.h#define M.pdf#includestdio.h#includestring.h#includestdlib.h#define M.pdf
#includestdio.h#includestring.h#includestdlib.h#define M.pdf
 
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdfC++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
 
reverse the linked list (2-4-8-10) by- stack- iteration- recursion- U.docx
reverse the linked list (2-4-8-10) by- stack- iteration- recursion-  U.docxreverse the linked list (2-4-8-10) by- stack- iteration- recursion-  U.docx
reverse the linked list (2-4-8-10) by- stack- iteration- recursion- U.docx
 
Lab-2.4 101.pdf
Lab-2.4 101.pdfLab-2.4 101.pdf
Lab-2.4 101.pdf
 
C++Write a method Node Nodereverse() which reverses a list..pdf
C++Write a method Node Nodereverse() which reverses a list..pdfC++Write a method Node Nodereverse() which reverses a list..pdf
C++Write a method Node Nodereverse() which reverses a list..pdf
 
Please write in C++ and should be able to compile and debug.Thank yo.pdf
Please write in C++ and should be able to compile and debug.Thank yo.pdfPlease write in C++ and should be able to compile and debug.Thank yo.pdf
Please write in C++ and should be able to compile and debug.Thank yo.pdf
 

More from adisainternational

Insert a function in cell D11 to display the ltem name based.pdf
Insert a function in cell D11 to display the ltem name based.pdfInsert a function in cell D11 to display the ltem name based.pdf
Insert a function in cell D11 to display the ltem name based.pdfadisainternational
 
Insert Document To Collection nbdaproject36vents VIEW P.pdf
Insert Document To Collection nbdaproject36vents VIEW  P.pdfInsert Document To Collection nbdaproject36vents VIEW  P.pdf
Insert Document To Collection nbdaproject36vents VIEW P.pdfadisainternational
 
innervates posterior 13 of tongue taste 2 Wordscran.pdf
innervates posterior 13 of tongue  taste  2 Wordscran.pdfinnervates posterior 13 of tongue  taste  2 Wordscran.pdf
innervates posterior 13 of tongue taste 2 Wordscran.pdfadisainternational
 
Individually look for the Code of Conduct of a selected comp.pdf
Individually look for the Code of Conduct of a selected comp.pdfIndividually look for the Code of Conduct of a selected comp.pdf
Individually look for the Code of Conduct of a selected comp.pdfadisainternational
 
Influenza is an infectious respiratory disease caused by a .pdf
Influenza is an infectious respiratory disease caused by a .pdfInfluenza is an infectious respiratory disease caused by a .pdf
Influenza is an infectious respiratory disease caused by a .pdfadisainternational
 
include ltstdiohgt include ltstdlibhgt include .pdf
include ltstdiohgt include ltstdlibhgt include .pdfinclude ltstdiohgt include ltstdlibhgt include .pdf
include ltstdiohgt include ltstdlibhgt include .pdfadisainternational
 
Informacin general Anna ha estado hablando con los director.pdf
Informacin general Anna ha estado hablando con los director.pdfInformacin general Anna ha estado hablando con los director.pdf
Informacin general Anna ha estado hablando con los director.pdfadisainternational
 
inflation in india interest rates in india and compare it wi.pdf
inflation in india interest rates in india and compare it wi.pdfinflation in india interest rates in india and compare it wi.pdf
inflation in india interest rates in india and compare it wi.pdfadisainternational
 
Indigenous Peoples and Environmental Sustainability Article .pdf
Indigenous Peoples and Environmental Sustainability Article .pdfIndigenous Peoples and Environmental Sustainability Article .pdf
Indigenous Peoples and Environmental Sustainability Article .pdfadisainternational
 
Information Security Problem a Give the public and private.pdf
Information Security Problem a Give the public and private.pdfInformation Security Problem a Give the public and private.pdf
Information Security Problem a Give the public and private.pdfadisainternational
 
Infertility and Hypothyroidism Patient ProfileMB is a 29y.pdf
Infertility and Hypothyroidism Patient ProfileMB is a 29y.pdfInfertility and Hypothyroidism Patient ProfileMB is a 29y.pdf
Infertility and Hypothyroidism Patient ProfileMB is a 29y.pdfadisainternational
 
inet at pemoning Bret is Bhen the nol asd atenene irpuinise .pdf
inet at pemoning Bret is Bhen the nol asd atenene irpuinise .pdfinet at pemoning Bret is Bhen the nol asd atenene irpuinise .pdf
inet at pemoning Bret is Bhen the nol asd atenene irpuinise .pdfadisainternational
 
Indique el diagnstico ms preciso posible Luego indique la.pdf
Indique el diagnstico ms preciso posible Luego indique la.pdfIndique el diagnstico ms preciso posible Luego indique la.pdf
Indique el diagnstico ms preciso posible Luego indique la.pdfadisainternational
 
In user interface design what is typically TRUE Group of a.pdf
In user interface design what is typically TRUE Group of a.pdfIn user interface design what is typically TRUE Group of a.pdf
In user interface design what is typically TRUE Group of a.pdfadisainternational
 
include ltinitializer_listgt include ltiostreamgt .pdf
include ltinitializer_listgt include ltiostreamgt .pdfinclude ltinitializer_listgt include ltiostreamgt .pdf
include ltinitializer_listgt include ltiostreamgt .pdfadisainternational
 
In your opinion What would drive your decisions If you wer.pdf
In your opinion What would drive your decisions If you wer.pdfIn your opinion What would drive your decisions If you wer.pdf
In your opinion What would drive your decisions If you wer.pdfadisainternational
 
Income statement for 2016 Sales are expected to increase by .pdf
Income statement for 2016 Sales are expected to increase by .pdfIncome statement for 2016 Sales are expected to increase by .pdf
Income statement for 2016 Sales are expected to increase by .pdfadisainternational
 
Indicate in the figure below the location of the Stratosphe.pdf
Indicate in the figure below the location of the Stratosphe.pdfIndicate in the figure below the location of the Stratosphe.pdf
Indicate in the figure below the location of the Stratosphe.pdfadisainternational
 
Independent ttest Dependentpaired ttest Oneway ANOVA Two.pdf
Independent ttest Dependentpaired ttest Oneway ANOVA Two.pdfIndependent ttest Dependentpaired ttest Oneway ANOVA Two.pdf
Independent ttest Dependentpaired ttest Oneway ANOVA Two.pdfadisainternational
 
Independent Assortment Two genes Dumb d and Anxious a .pdf
Independent Assortment Two genes Dumb d and Anxious a .pdfIndependent Assortment Two genes Dumb d and Anxious a .pdf
Independent Assortment Two genes Dumb d and Anxious a .pdfadisainternational
 

More from adisainternational (20)

Insert a function in cell D11 to display the ltem name based.pdf
Insert a function in cell D11 to display the ltem name based.pdfInsert a function in cell D11 to display the ltem name based.pdf
Insert a function in cell D11 to display the ltem name based.pdf
 
Insert Document To Collection nbdaproject36vents VIEW P.pdf
Insert Document To Collection nbdaproject36vents VIEW  P.pdfInsert Document To Collection nbdaproject36vents VIEW  P.pdf
Insert Document To Collection nbdaproject36vents VIEW P.pdf
 
innervates posterior 13 of tongue taste 2 Wordscran.pdf
innervates posterior 13 of tongue  taste  2 Wordscran.pdfinnervates posterior 13 of tongue  taste  2 Wordscran.pdf
innervates posterior 13 of tongue taste 2 Wordscran.pdf
 
Individually look for the Code of Conduct of a selected comp.pdf
Individually look for the Code of Conduct of a selected comp.pdfIndividually look for the Code of Conduct of a selected comp.pdf
Individually look for the Code of Conduct of a selected comp.pdf
 
Influenza is an infectious respiratory disease caused by a .pdf
Influenza is an infectious respiratory disease caused by a .pdfInfluenza is an infectious respiratory disease caused by a .pdf
Influenza is an infectious respiratory disease caused by a .pdf
 
include ltstdiohgt include ltstdlibhgt include .pdf
include ltstdiohgt include ltstdlibhgt include .pdfinclude ltstdiohgt include ltstdlibhgt include .pdf
include ltstdiohgt include ltstdlibhgt include .pdf
 
Informacin general Anna ha estado hablando con los director.pdf
Informacin general Anna ha estado hablando con los director.pdfInformacin general Anna ha estado hablando con los director.pdf
Informacin general Anna ha estado hablando con los director.pdf
 
inflation in india interest rates in india and compare it wi.pdf
inflation in india interest rates in india and compare it wi.pdfinflation in india interest rates in india and compare it wi.pdf
inflation in india interest rates in india and compare it wi.pdf
 
Indigenous Peoples and Environmental Sustainability Article .pdf
Indigenous Peoples and Environmental Sustainability Article .pdfIndigenous Peoples and Environmental Sustainability Article .pdf
Indigenous Peoples and Environmental Sustainability Article .pdf
 
Information Security Problem a Give the public and private.pdf
Information Security Problem a Give the public and private.pdfInformation Security Problem a Give the public and private.pdf
Information Security Problem a Give the public and private.pdf
 
Infertility and Hypothyroidism Patient ProfileMB is a 29y.pdf
Infertility and Hypothyroidism Patient ProfileMB is a 29y.pdfInfertility and Hypothyroidism Patient ProfileMB is a 29y.pdf
Infertility and Hypothyroidism Patient ProfileMB is a 29y.pdf
 
inet at pemoning Bret is Bhen the nol asd atenene irpuinise .pdf
inet at pemoning Bret is Bhen the nol asd atenene irpuinise .pdfinet at pemoning Bret is Bhen the nol asd atenene irpuinise .pdf
inet at pemoning Bret is Bhen the nol asd atenene irpuinise .pdf
 
Indique el diagnstico ms preciso posible Luego indique la.pdf
Indique el diagnstico ms preciso posible Luego indique la.pdfIndique el diagnstico ms preciso posible Luego indique la.pdf
Indique el diagnstico ms preciso posible Luego indique la.pdf
 
In user interface design what is typically TRUE Group of a.pdf
In user interface design what is typically TRUE Group of a.pdfIn user interface design what is typically TRUE Group of a.pdf
In user interface design what is typically TRUE Group of a.pdf
 
include ltinitializer_listgt include ltiostreamgt .pdf
include ltinitializer_listgt include ltiostreamgt .pdfinclude ltinitializer_listgt include ltiostreamgt .pdf
include ltinitializer_listgt include ltiostreamgt .pdf
 
In your opinion What would drive your decisions If you wer.pdf
In your opinion What would drive your decisions If you wer.pdfIn your opinion What would drive your decisions If you wer.pdf
In your opinion What would drive your decisions If you wer.pdf
 
Income statement for 2016 Sales are expected to increase by .pdf
Income statement for 2016 Sales are expected to increase by .pdfIncome statement for 2016 Sales are expected to increase by .pdf
Income statement for 2016 Sales are expected to increase by .pdf
 
Indicate in the figure below the location of the Stratosphe.pdf
Indicate in the figure below the location of the Stratosphe.pdfIndicate in the figure below the location of the Stratosphe.pdf
Indicate in the figure below the location of the Stratosphe.pdf
 
Independent ttest Dependentpaired ttest Oneway ANOVA Two.pdf
Independent ttest Dependentpaired ttest Oneway ANOVA Two.pdfIndependent ttest Dependentpaired ttest Oneway ANOVA Two.pdf
Independent ttest Dependentpaired ttest Oneway ANOVA Two.pdf
 
Independent Assortment Two genes Dumb d and Anxious a .pdf
Independent Assortment Two genes Dumb d and Anxious a .pdfIndependent Assortment Two genes Dumb d and Anxious a .pdf
Independent Assortment Two genes Dumb d and Anxious a .pdf
 

Recently uploaded

ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptxPoojaSen20
 
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya - UEM Kolkata Quiz Club
 
Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
 Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatmentsaipooja36
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdfVikramadityaRaj
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnershipsexpandedwebsite
 
HVAC System | Audit of HVAC System | Audit and regulatory Comploance.pptx
HVAC System | Audit of HVAC System | Audit and regulatory Comploance.pptxHVAC System | Audit of HVAC System | Audit and regulatory Comploance.pptx
HVAC System | Audit of HVAC System | Audit and regulatory Comploance.pptxKunal10679
 
MichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfMichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfmstarkes24
 
Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Celine George
 
REPRODUCTIVE TOXICITY STUDIE OF MALE AND FEMALEpptx
REPRODUCTIVE TOXICITY  STUDIE OF MALE AND FEMALEpptxREPRODUCTIVE TOXICITY  STUDIE OF MALE AND FEMALEpptx
REPRODUCTIVE TOXICITY STUDIE OF MALE AND FEMALEpptxmanishaJyala2
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticspragatimahajan3
 
Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024CapitolTechU
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...Nguyen Thanh Tu Collection
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxheathfieldcps1
 
Navigating the Misinformation Minefield: The Role of Higher Education in the ...
Navigating the Misinformation Minefield: The Role of Higher Education in the ...Navigating the Misinformation Minefield: The Role of Higher Education in the ...
Navigating the Misinformation Minefield: The Role of Higher Education in the ...Mark Carrigan
 
An Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxAn Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxCeline George
 
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Denish Jangid
 

Recently uploaded (20)

ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
 
Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
 Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
HVAC System | Audit of HVAC System | Audit and regulatory Comploance.pptx
HVAC System | Audit of HVAC System | Audit and regulatory Comploance.pptxHVAC System | Audit of HVAC System | Audit and regulatory Comploance.pptx
HVAC System | Audit of HVAC System | Audit and regulatory Comploance.pptx
 
MichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfMichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdf
 
Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17
 
REPRODUCTIVE TOXICITY STUDIE OF MALE AND FEMALEpptx
REPRODUCTIVE TOXICITY  STUDIE OF MALE AND FEMALEpptxREPRODUCTIVE TOXICITY  STUDIE OF MALE AND FEMALEpptx
REPRODUCTIVE TOXICITY STUDIE OF MALE AND FEMALEpptx
 
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceutics
 
“O BEIJO” EM ARTE .
“O BEIJO” EM ARTE                       .“O BEIJO” EM ARTE                       .
“O BEIJO” EM ARTE .
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 
Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024
 
IPL Online Quiz by Pragya; Question Set.
IPL Online Quiz by Pragya; Question Set.IPL Online Quiz by Pragya; Question Set.
IPL Online Quiz by Pragya; Question Set.
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
Navigating the Misinformation Minefield: The Role of Higher Education in the ...
Navigating the Misinformation Minefield: The Role of Higher Education in the ...Navigating the Misinformation Minefield: The Role of Higher Education in the ...
Navigating the Misinformation Minefield: The Role of Higher Education in the ...
 
An Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxAn Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptx
 
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
 

include getopt in this code with the usage doublesort d.pdf

  • 1. include getopt in this code with the usage % doublesort [-d] [-o output_file_name] input_file_name: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> typedef struct node { char* data; struct node* prev; struct node* next; } Node; Node* create_node(char* data) { Node* new_node = malloc(sizeof(Node)); new_node->data = malloc(strlen(data) + 1); strcpy(new_node->data, data); new_node->prev = NULL; new_node->next = NULL; return new_node; } void insert_node(Node** head, Node* new_node) { if (*head == NULL) { *head = new_node; return; } Node* current_node = *head; while (current_node->next != NULL && strcmp(new_node->data, current_node->data) > 0) { current_node = current_node->next; } if (current_node->next == NULL && strcmp(new_node->data, current_node->data) > 0) { current_node->next = new_node; new_node->prev = current_node; return; } Node* prev_node = current_node->prev; if (prev_node == NULL) { *head = new_node; } else { prev_node->next = new_node; } new_node->prev = prev_node; new_node->next = current_node; current_node->prev = new_node; }
  • 2. void print_list(Node* head, FILE* output_file) { while (head != NULL) { fprintf(output_file, "%sn", head->data); head = head->next; } } void convert_to_lowercase(char* string) { for (int i = 0; string[i]; i++) { string[i] = tolower(string[i]); } } int main(int argc, char* argv[]) { if (argc != 2) { printf("Usage: %s input_filen", argv[0]); return 1; } FILE* input_file = fopen(argv[1], "r"); if (input_file == NULL) { printf("Could not open file %sn", argv[1]); return 1; } Node* head = NULL; char buffer[100]; while (fgets(buffer, sizeof(buffer), input_file)) { char* token = strtok(buffer, " tn"); while (token != NULL) { convert_to_lowercase(token); Node* new_node = create_node(token); insert_node(&head, new_node); token = strtok(NULL, " tn"); } } fclose(input_file); print_list(head, stdout); return 0; }