0

I have this struct for an item in a to-do list

struct Task {
	char description[TASK_DESC_SIZE];  	/* description of the task */
	int priority;			  			/* task priority */  
};

i'm just not sure how to alter the description while making a task using this

TYPE createTask (int priority, char *desc) 
{
	struct Task* t = (struct Task*)malloc(sizeof(struct Task));
	t->description = *desc;
	t->priority = priority;
	return *t;
}

I would love to know how to change the description.

1
Contributor
1
Reply
3
Views
6 Years
Discussion Span
Last Post by Vorwerkj
0

nevermind. I fixed it with this

TYPE createTask (int priority, char *desc) 
{
	struct Task* t = (struct Task*)malloc(sizeof(struct Task));
	strcpy(t->description, desc);
	return *t;
	
}

Edited by Vorwerkj: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.