All pastes #277153 Raw Edit

Miscellany

public c v1 · immutable
·published 2006-12-12 23:30 UTC
rendered paste body
void ListAddItem(LIST *list, const char *strItem, int *total) {	int szItem = strlen(strItem)+1, t;	t = get_y(strItem);	if(t + (*total) > 150) //warnning for exceding 150	{		printf("Total value of y exeed 150\n"); //error message		return;	}	*total = *total + t; //still less than 150, so add this to total	// allocate memory then copy item to new memory (store location of memory in pItems)	list->pItems[list->nItems] = malloc(szItem);	strcpy(list->pItems[list->nItems], strItem);	// increase the number of items in the list counter	list->nItems++;	// allocate enough memory for next pointer to be stored	list->pItems = realloc(list->pItems, sizeof(char *)*(list->nItems+1));}