Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN PROGRAMMING LANGUAGE C -This code creates a linked list I would like to know how to copy my contents from my linked list into

IN PROGRAMMING LANGUAGE C

-This code creates a linked list I would like to know how to copy my contents from my linked list into an array of characters ?

#include

#include

#include

#include

struct Node{

void *data;

struct Node *next;

};

void push(struct Node** head_ref, void *new_data, size_t data_size){

// Allocate meory for node

struct Node* new_node = (struct Node*)malloc(sizeof(struct Node));

new_node->data = malloc(data_size);

new_node->next = (*head_ref);

int i =0;

for(i =0; i

*(char *)(new_node->data +i) = *(char *)(new_data +i);

(*head_ref) = new_node;

}

}

void printList(struct Node *node, void(*fptr) (void *)){

while(node !=NULL){

(*fptr)(node->data);

node = node->next;

}

}

void printString(void *c){

printf("%c",*(char *)c);

}

int main(int argc, char*argv[]){

struct Node *start = NULL;

int length = strlen(argv[1]);

int i =0;

int pos = -1;

for(i = length;i>=0;i--){

if(isalpha(argv[1][i])!= 0||isdigit(argv[1][i] == 0)){

push(&start,&argv[1][i],length);

}

}

printList(start,printString);

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Privacy In Statistical Databases International Conference Psd 2022 Paris France September 21 23 2022 Proceedings Lncs 13463

Authors: Josep Domingo-Ferrer ,Maryline Laurent

1st Edition

3031139445, 978-3031139444

More Books

Students also viewed these Databases questions

Question

4. What is Title VII? What does it state?

Answered: 1 week ago

Question

Define Administration and Management

Answered: 1 week ago

Question

Define organisational structure

Answered: 1 week ago

Question

Define line and staff authority

Answered: 1 week ago