Hi, I am able to compile successfully. But I found just minor problem where compiler said "[Warning] unknown escape sequence '\>' "
Could you please fix as soon as possible. Need to submit assign today
Code:#include<stdio.h> #include<string.h> #include<stdlib.h> #define STR_SIZE 100 struct node { char data; struct node *next; }; void start(void); void getString(void); void makeLinkList(struct node *head); void printInPutStr(struct node *head); int getNumber(void); void replaceNode(int inPut, struct node *head); void printOutPutStr(struct node *head); void printStr(struct node *head); void end(void); void emptyLinkedList(struct node *head); char inPutStr[STR_SIZE]; int number; int main(void) { char inPutChar; // USED AS PART OF PROGRAM TERMINATION int inPut; // HOLDS VALUE OF INDEX ENTERED BY THE USER struct node *head = NULL; // SAME int count; // INDEX VALUE printf("\n Data Flow Structures & Linked Lists"); printf("\n -----------------------------------------------------------------\n\n"); printf(" USER INSTRUCTIONS \n"); printf(" > Write a program that creates a linked list of characters from a string \n"); printf(" > entered by the user.\n"); printf(" > The program is then to accept a second string and an index from the user. \n"); printf(" > The second string is then to be inserted into the first string at the \n"); printf(" > location given by the index. \n\n"); start(); getString(); head = (struct node*) calloc(1, sizeof (struct node)); makeLinkList(head); printInPutStr(head); inPut = getNumber(); replaceNode(inPut, head); printOutPutStr(head); end(); } void start(void) { printf(" STARTING PROGRAM...\n"); } void getString(void) { printf(" Please enter a string (Maximum length %d characters) \n\t C:\> ", STR_SIZE); gets(inPutStr); fflush(stdin); while(inPutStr[0] == 0 || inPutStr[0] == ' ') { printf("\n\t NOTHING INSERTED! RE-ENTER A STRING \n\t C:\> "); gets(inPutStr); fflush(stdin); } } void makeLinkList(struct node *head) { struct node *current, *previous; int i; current = head; current->next = (struct node*)calloc(1, sizeof(struct node)); current=current->next; for ( i = 0 ; inPutStr[i] != 0 ; ++i ) { current->data= inPutStr[i]; current->next = (struct node*)calloc(1, sizeof(struct node)); previous = current; current = current->next; } free(current); previous->next = NULL; current = head; } void printInPutStr(struct node *head) { printf("\n USER INPUT:\n > "); emptyLinkedList(head); printStr(head); } int getNumber(void) { int inP1, inP2; printf("\n\n Enter Index value \n\t C:\> ", STR_SIZE); scanf("%d",&inP1); fflush(stdin); while(inP1<1) { printf("\n\t INVALID ENTRY! RE-ENTER DIGIT \n\t C:\> "); scanf("%d",&inP1); fflush(stdin); } return (inP1); } void replaceNode(int inPut, struct node *head) { struct node *current, *previous, *forward; int i=0,j=0; int l,c; l=inPut; current = head; for( ; j<l; j++) { current=current->next; } while (current!=NULL) { inPutStr[i]=current->data; current=current->next; i++; } current = head; j=0; while(j<=l+1) { inPutStr[i]=current->data; current=current->next; i++; j++; } current = head; i=0; while(current!=NULL) { current->data = inPutStr[i]; i++; current = current->next; } } void printOutPutStr(struct node *head) { printf("\n MODIFIED STRING:\n > "); emptyLinkedList(head); printStr(head); } void printStr(struct node *head) { struct node *current; current = head; do { current = current->next; printf("%c", current->data); } while(current->next != NULL); } void end(void) { char inPutChar; printf(" PRESS ANY KEY TO EXIT PROGRAM...\n"); scanf("%c",&inPutChar); fflush(stdin); } void emptyLinkedList(struct node *head) { if(head->next == NULL) { printf("\Empty Linked List!!!!"); } }



LinkBack URL
About LinkBacks



I used to be an adventurer like you... then I took an arrow to the knee.