I have just started with Functions with variable-length argument lists, and I thought i would try using it to "optimise" one of the functions I already have. I have tryed implementing it, the compiler produces not errors/warnings, so when run the program crashes. Here is what I have currently:
I know the for loop needs fixing (its probably col!=0 [i've tried !=NULL same thing happens]) but I don't know how to fix this. Any ideas? I think (hope) this is code stright forward, if not say and I will post the old code (longer, but works).Code:void InsertRow(HWND hwnd, char *col1, char *col, ...) { LV_ITEM lvItem; va_list arguments; int i; lvItem.mask = 0; lvItem.iItem = 0; lvItem.iSubItem = 0; lvItem.iItem = ListView_InsertItem (hwnd, &lvItem); lvItem.mask = LVIF_TEXT; lvItem.pszText = col1; lvItem.cchTextMax = strlen (lvItem.pszText); ListView_SetItem(hwnd, &lvItem); va_start (arguments, col); for (i=0; col!=0; i++) { lvItem.iSubItem = (i+1); lvItem.pszText = va_arg ( arguments, char *); ListView_SetItem(hwnd, &lvItem); } va_end (arguments); }



LinkBack URL
About LinkBacks



