SlideShare una empresa de Scribd logo
1 de 3
Descargar para leer sin conexión
include getopt in this code with the usage % doublesort [-d] [-o output_file_name]
input_file_name:
#include
#include
#include
#include
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;
}

Más contenido relacionado

Similar a include getopt in this code with the usage doublesort [-d] [-o out.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 .pdffathimahardwareelect
 
This code currently works... Run it and get a screen shot of its .docx
 This code currently works... Run it and get a screen shot of its .docx This code currently works... Run it and get a screen shot of its .docx
This code currently works... Run it and get a screen shot of its .docxKomlin1
 
computer notes - Data Structures - 3
computer notes - Data Structures - 3computer notes - Data Structures - 3
computer notes - Data Structures - 3ecomputernotes
 
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
 
includestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdfincludestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdfgalagirishp
 
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
 
include ltiostreamgt include ltfstreamgt in.pdf
include ltiostreamgt include ltfstreamgt in.pdfinclude ltiostreamgt include ltfstreamgt in.pdf
include ltiostreamgt include ltfstreamgt in.pdfadisainternational
 
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfDoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfaathiauto
 
Implement of c & its coding programming by sarmad baloch
Implement of c & its coding  programming by sarmad balochImplement of c & its coding  programming by sarmad baloch
Implement of c & its coding programming by sarmad balochSarmad Baloch
 
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
 
#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
 
write recursive function that calculates and returns the length of a.pdf
write recursive function that calculates and returns the length of a.pdfwrite recursive function that calculates and returns the length of a.pdf
write recursive function that calculates and returns the length of a.pdfarpitcomputronics
 
operating system linux,ubuntu,Mac#include iostream #include .pdf
operating system linux,ubuntu,Mac#include iostream #include .pdfoperating system linux,ubuntu,Mac#include iostream #include .pdf
operating system linux,ubuntu,Mac#include iostream #include .pdfaquacareser
 
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
 
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
 
20-13 Programming Project #05A Given the IntNode class- define the Fin.docx
20-13 Programming Project #05A Given the IntNode class- define the Fin.docx20-13 Programming Project #05A Given the IntNode class- define the Fin.docx
20-13 Programming Project #05A Given the IntNode class- define the Fin.docxDavidxyNSimpsons
 

Similar a include getopt in this code with the usage doublesort [-d] [-o out.pdf (20)

DS Code (CWH).docx
DS Code (CWH).docxDS Code (CWH).docx
DS Code (CWH).docx
 
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
 
This code currently works... Run it and get a screen shot of its .docx
 This code currently works... Run it and get a screen shot of its .docx This code currently works... Run it and get a screen shot of its .docx
This code currently works... Run it and get a screen shot of its .docx
 
computer notes - Data Structures - 3
computer notes - Data Structures - 3computer notes - Data Structures - 3
computer notes - Data Structures - 3
 
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
 
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
 
includestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdfincludestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdf
 
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
 
include ltiostreamgt include ltfstreamgt in.pdf
include ltiostreamgt include ltfstreamgt in.pdfinclude ltiostreamgt include ltfstreamgt in.pdf
include ltiostreamgt include ltfstreamgt in.pdf
 
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfDoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
 
Implement of c & its coding programming by sarmad baloch
Implement of c & its coding  programming by sarmad balochImplement of c & its coding  programming by sarmad baloch
Implement of c & its coding programming by sarmad baloch
 
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
 
#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
 
write recursive function that calculates and returns the length of a.pdf
write recursive function that calculates and returns the length of a.pdfwrite recursive function that calculates and returns the length of a.pdf
write recursive function that calculates and returns the length of a.pdf
 
operating system linux,ubuntu,Mac#include iostream #include .pdf
operating system linux,ubuntu,Mac#include iostream #include .pdfoperating system linux,ubuntu,Mac#include iostream #include .pdf
operating system linux,ubuntu,Mac#include iostream #include .pdf
 
DSA(1).pptx
DSA(1).pptxDSA(1).pptx
DSA(1).pptx
 
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
 
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
 
20-13 Programming Project #05A Given the IntNode class- define the Fin.docx
20-13 Programming Project #05A Given the IntNode class- define the Fin.docx20-13 Programming Project #05A Given the IntNode class- define the Fin.docx
20-13 Programming Project #05A Given the IntNode class- define the Fin.docx
 

Más de aggarwalenterprisesf

it must give every word aloneand Root disables it Stemming is th.pdf
it must give every word aloneand Root disables it Stemming is th.pdfit must give every word aloneand Root disables it Stemming is th.pdf
it must give every word aloneand Root disables it Stemming is th.pdfaggarwalenterprisesf
 
Introducci�n al paciente Eva Madison es una ni�a cauc�sica de 5 .pdf
Introducci�n al paciente Eva Madison es una ni�a cauc�sica de 5 .pdfIntroducci�n al paciente Eva Madison es una ni�a cauc�sica de 5 .pdf
Introducci�n al paciente Eva Madison es una ni�a cauc�sica de 5 .pdfaggarwalenterprisesf
 
Insert the correct words into the blanks in the textThe protein.pdf
Insert the correct words into the blanks in the textThe protein.pdfInsert the correct words into the blanks in the textThe protein.pdf
Insert the correct words into the blanks in the textThe protein.pdfaggarwalenterprisesf
 
It is currently January 2011 and the futures price for June WTI cru.pdf
It is currently January 2011 and the futures price for June WTI cru.pdfIt is currently January 2011 and the futures price for June WTI cru.pdf
It is currently January 2011 and the futures price for June WTI cru.pdfaggarwalenterprisesf
 
It has been estimated that only about 30 of California residents ha.pdf
It has been estimated that only about 30 of California residents ha.pdfIt has been estimated that only about 30 of California residents ha.pdf
It has been estimated that only about 30 of California residents ha.pdfaggarwalenterprisesf
 
Irkanias aggregate Irkanias aggregate expenditures function is sho.pdf
Irkanias aggregate Irkanias aggregate expenditures function is sho.pdfIrkanias aggregate Irkanias aggregate expenditures function is sho.pdf
Irkanias aggregate Irkanias aggregate expenditures function is sho.pdfaggarwalenterprisesf
 
Irene, yerel bir kolejdeki �renciler hakknda bilgi topluyor. te topl.pdf
Irene, yerel bir kolejdeki �renciler hakknda bilgi topluyor. te topl.pdfIrene, yerel bir kolejdeki �renciler hakknda bilgi topluyor. te topl.pdf
Irene, yerel bir kolejdeki �renciler hakknda bilgi topluyor. te topl.pdfaggarwalenterprisesf
 
Issue the commandscript BackupCommandsThis command will record .pdf
Issue the commandscript BackupCommandsThis command will record .pdfIssue the commandscript BackupCommandsThis command will record .pdf
Issue the commandscript BackupCommandsThis command will record .pdfaggarwalenterprisesf
 
irket bakan, �ou posta yoluyla ve dierleri irketin intraneti araclyl.pdf
irket bakan, �ou posta yoluyla ve dierleri irketin intraneti araclyl.pdfirket bakan, �ou posta yoluyla ve dierleri irketin intraneti araclyl.pdf
irket bakan, �ou posta yoluyla ve dierleri irketin intraneti araclyl.pdfaggarwalenterprisesf
 
Investigue Halcones de cola roja usando la enciclopedia en l�nea All.pdf
Investigue Halcones de cola roja usando la enciclopedia en l�nea All.pdfInvestigue Halcones de cola roja usando la enciclopedia en l�nea All.pdf
Investigue Halcones de cola roja usando la enciclopedia en l�nea All.pdfaggarwalenterprisesf
 
Introducci�nCochinillas En el ejercicio de hoy, utilizaremos el.pdf
Introducci�nCochinillas En el ejercicio de hoy, utilizaremos el.pdfIntroducci�nCochinillas En el ejercicio de hoy, utilizaremos el.pdf
Introducci�nCochinillas En el ejercicio de hoy, utilizaremos el.pdfaggarwalenterprisesf
 
Introducci�n El vocabulario, como una de las �reas de conocimient.pdf
Introducci�n El vocabulario, como una de las �reas de conocimient.pdfIntroducci�n El vocabulario, como una de las �reas de conocimient.pdf
Introducci�n El vocabulario, como una de las �reas de conocimient.pdfaggarwalenterprisesf
 
Internet providers can be considered a monopoly where consumers have.pdf
Internet providers can be considered a monopoly where consumers have.pdfInternet providers can be considered a monopoly where consumers have.pdf
Internet providers can be considered a monopoly where consumers have.pdfaggarwalenterprisesf
 
Instructions The paper should be in APA format with 3-4 pages doubl.pdf
Instructions The paper should be in APA format with 3-4 pages doubl.pdfInstructions The paper should be in APA format with 3-4 pages doubl.pdf
Instructions The paper should be in APA format with 3-4 pages doubl.pdfaggarwalenterprisesf
 
InstructionsAssume that your class group has been selected and hir.pdf
InstructionsAssume that your class group has been selected and hir.pdfInstructionsAssume that your class group has been selected and hir.pdf
InstructionsAssume that your class group has been selected and hir.pdfaggarwalenterprisesf
 
Instrucciones Imagine que forma parte de un equipo de investigaci�.pdf
Instrucciones Imagine que forma parte de un equipo de investigaci�.pdfInstrucciones Imagine que forma parte de un equipo de investigaci�.pdf
Instrucciones Imagine que forma parte de un equipo de investigaci�.pdfaggarwalenterprisesf
 
In what way are the emerging trends of working couples, lower birthr.pdf
In what way are the emerging trends of working couples, lower birthr.pdfIn what way are the emerging trends of working couples, lower birthr.pdf
In what way are the emerging trends of working couples, lower birthr.pdfaggarwalenterprisesf
 
In this assignment, you examine the Supreme Court case of Terry v. O.pdf
In this assignment, you examine the Supreme Court case of Terry v. O.pdfIn this assignment, you examine the Supreme Court case of Terry v. O.pdf
In this assignment, you examine the Supreme Court case of Terry v. O.pdfaggarwalenterprisesf
 
In the SS partnership (to which Fozzie seeks admittance), the capita.pdf
In the SS partnership (to which Fozzie seeks admittance), the capita.pdfIn the SS partnership (to which Fozzie seeks admittance), the capita.pdf
In the SS partnership (to which Fozzie seeks admittance), the capita.pdfaggarwalenterprisesf
 
IN PYTHONCreate your own list of random integers, do not use r.pdf
IN PYTHONCreate your own list of random integers, do not use r.pdfIN PYTHONCreate your own list of random integers, do not use r.pdf
IN PYTHONCreate your own list of random integers, do not use r.pdfaggarwalenterprisesf
 

Más de aggarwalenterprisesf (20)

it must give every word aloneand Root disables it Stemming is th.pdf
it must give every word aloneand Root disables it Stemming is th.pdfit must give every word aloneand Root disables it Stemming is th.pdf
it must give every word aloneand Root disables it Stemming is th.pdf
 
Introducci�n al paciente Eva Madison es una ni�a cauc�sica de 5 .pdf
Introducci�n al paciente Eva Madison es una ni�a cauc�sica de 5 .pdfIntroducci�n al paciente Eva Madison es una ni�a cauc�sica de 5 .pdf
Introducci�n al paciente Eva Madison es una ni�a cauc�sica de 5 .pdf
 
Insert the correct words into the blanks in the textThe protein.pdf
Insert the correct words into the blanks in the textThe protein.pdfInsert the correct words into the blanks in the textThe protein.pdf
Insert the correct words into the blanks in the textThe protein.pdf
 
It is currently January 2011 and the futures price for June WTI cru.pdf
It is currently January 2011 and the futures price for June WTI cru.pdfIt is currently January 2011 and the futures price for June WTI cru.pdf
It is currently January 2011 and the futures price for June WTI cru.pdf
 
It has been estimated that only about 30 of California residents ha.pdf
It has been estimated that only about 30 of California residents ha.pdfIt has been estimated that only about 30 of California residents ha.pdf
It has been estimated that only about 30 of California residents ha.pdf
 
Irkanias aggregate Irkanias aggregate expenditures function is sho.pdf
Irkanias aggregate Irkanias aggregate expenditures function is sho.pdfIrkanias aggregate Irkanias aggregate expenditures function is sho.pdf
Irkanias aggregate Irkanias aggregate expenditures function is sho.pdf
 
Irene, yerel bir kolejdeki �renciler hakknda bilgi topluyor. te topl.pdf
Irene, yerel bir kolejdeki �renciler hakknda bilgi topluyor. te topl.pdfIrene, yerel bir kolejdeki �renciler hakknda bilgi topluyor. te topl.pdf
Irene, yerel bir kolejdeki �renciler hakknda bilgi topluyor. te topl.pdf
 
Issue the commandscript BackupCommandsThis command will record .pdf
Issue the commandscript BackupCommandsThis command will record .pdfIssue the commandscript BackupCommandsThis command will record .pdf
Issue the commandscript BackupCommandsThis command will record .pdf
 
irket bakan, �ou posta yoluyla ve dierleri irketin intraneti araclyl.pdf
irket bakan, �ou posta yoluyla ve dierleri irketin intraneti araclyl.pdfirket bakan, �ou posta yoluyla ve dierleri irketin intraneti araclyl.pdf
irket bakan, �ou posta yoluyla ve dierleri irketin intraneti araclyl.pdf
 
Investigue Halcones de cola roja usando la enciclopedia en l�nea All.pdf
Investigue Halcones de cola roja usando la enciclopedia en l�nea All.pdfInvestigue Halcones de cola roja usando la enciclopedia en l�nea All.pdf
Investigue Halcones de cola roja usando la enciclopedia en l�nea All.pdf
 
Introducci�nCochinillas En el ejercicio de hoy, utilizaremos el.pdf
Introducci�nCochinillas En el ejercicio de hoy, utilizaremos el.pdfIntroducci�nCochinillas En el ejercicio de hoy, utilizaremos el.pdf
Introducci�nCochinillas En el ejercicio de hoy, utilizaremos el.pdf
 
Introducci�n El vocabulario, como una de las �reas de conocimient.pdf
Introducci�n El vocabulario, como una de las �reas de conocimient.pdfIntroducci�n El vocabulario, como una de las �reas de conocimient.pdf
Introducci�n El vocabulario, como una de las �reas de conocimient.pdf
 
Internet providers can be considered a monopoly where consumers have.pdf
Internet providers can be considered a monopoly where consumers have.pdfInternet providers can be considered a monopoly where consumers have.pdf
Internet providers can be considered a monopoly where consumers have.pdf
 
Instructions The paper should be in APA format with 3-4 pages doubl.pdf
Instructions The paper should be in APA format with 3-4 pages doubl.pdfInstructions The paper should be in APA format with 3-4 pages doubl.pdf
Instructions The paper should be in APA format with 3-4 pages doubl.pdf
 
InstructionsAssume that your class group has been selected and hir.pdf
InstructionsAssume that your class group has been selected and hir.pdfInstructionsAssume that your class group has been selected and hir.pdf
InstructionsAssume that your class group has been selected and hir.pdf
 
Instrucciones Imagine que forma parte de un equipo de investigaci�.pdf
Instrucciones Imagine que forma parte de un equipo de investigaci�.pdfInstrucciones Imagine que forma parte de un equipo de investigaci�.pdf
Instrucciones Imagine que forma parte de un equipo de investigaci�.pdf
 
In what way are the emerging trends of working couples, lower birthr.pdf
In what way are the emerging trends of working couples, lower birthr.pdfIn what way are the emerging trends of working couples, lower birthr.pdf
In what way are the emerging trends of working couples, lower birthr.pdf
 
In this assignment, you examine the Supreme Court case of Terry v. O.pdf
In this assignment, you examine the Supreme Court case of Terry v. O.pdfIn this assignment, you examine the Supreme Court case of Terry v. O.pdf
In this assignment, you examine the Supreme Court case of Terry v. O.pdf
 
In the SS partnership (to which Fozzie seeks admittance), the capita.pdf
In the SS partnership (to which Fozzie seeks admittance), the capita.pdfIn the SS partnership (to which Fozzie seeks admittance), the capita.pdf
In the SS partnership (to which Fozzie seeks admittance), the capita.pdf
 
IN PYTHONCreate your own list of random integers, do not use r.pdf
IN PYTHONCreate your own list of random integers, do not use r.pdfIN PYTHONCreate your own list of random integers, do not use r.pdf
IN PYTHONCreate your own list of random integers, do not use r.pdf
 

Último

Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
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
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
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
 
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
 
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
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
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
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
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
 

Último (20)

Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
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
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
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...
 
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...
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
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...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
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 byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
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
 
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
 

include getopt in this code with the usage doublesort [-d] [-o out.pdf

  • 1. include getopt in this code with the usage % doublesort [-d] [-o output_file_name] input_file_name: #include #include #include #include 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;
  • 2. 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]);
  • 3. 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; }