Question: #include #include typedef struct node { char letter; struct node* next; } node; // Returns number of nodes in the linkedList. int length(node* head) {

 #include #include typedef struct node { char letter; struct node* next;

#include

#include

typedef struct node {

char letter;

struct node* next;

} node;

// Returns number of nodes in the linkedList.

int length(node* head)

{

}

// parses the string in the linkedList

// if the linked list is head -> |a|->|b|->|c|

// then toCString function wil return "abc"

char* toCString(node* head)

{

}

// inserts character to the linkedlist

// f the linked list is head -> |a|->|b|->|c|

// then insertChar(&head, 'x') will update the linked list as foolows:

// head -> |a|->|b|->|c|->|x|

void insertChar(node** pHead, char c)

{

}

// deletes all nodes in the linkedList.

void deleteList(node** pHead)

{

}

int main(void)

{

int i, strLen, numInputs;

node* head = NULL;

char* str;

char c;

FILE* inFile = fopen("input.txt","r");

fscanf(inFile, " %d ", &numInputs);

while (numInputs-- > 0)

{

fscanf(inFile, " %d ", &strLen);

for (i = 0; i

{

fscanf(inFile," %c", &c);

insertChar(&head, c);

}

str = toCString(head);

printf("String is : %s ", str);

free(str);

deleteList(&head);

if (head != NULL)

{

printf("deleteList is not correct!");

break;

}

}

fclose(inFile);

}

Expected Output

String is : (abcdef) String is : (1234) String is : (cm)

An alternate method of storing a string is to store each letter of the string in a single node of a linked list, with the first node of the list storing the first letter of the string. Using this method of storage, no null character is needed since the next field of the node storing the last letter of the string would simply be a null pointer. In this program, you are going to complete the missing below functions in the attached C-file. This program reads the input from the attached input.txt file in the following format: 3 6 abcdef 4 1234 2 cm When the chars "abcdef" are read, your program will construct a linked list as follows: You are going to implement the following functions: int length(node* head) char* tocstring(node* head) void insertChar (node** pHead, char c) void deleteList (node pHead)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!