|
From: nemesia31 on 26 Sep 2006 23:56 i have a structure typedef struct tm { int date; int hour; int minutes; } time; i want to use this structure dynamically, ie, i want it to grow. like it would be time *sept= new time; sept->date=15; ...... ......... ....... but i want something like for(int i=0;i<MAX;i++) { sept[i]->date=i+5; } i want to grow the structure dynamically, ie, the valur of MAX is provided at runtime. how can i do tht????
From: Jerry Coffin on 27 Sep 2006 00:19 In article <1159329398.445690.72770(a)k70g2000cwa.googlegroups.com>, nemesia31(a)gmail.com says... > i have a structure > typedef struct tm > { > int date; > int hour; > int minutes; > } time; Your names (tm and time) are both _very_ poorly chosen. The standard library already defines both of these. OTOH, you might want to consider using struct tm from the standard library -- it's a more comprehensive version of what you have here. > i want to use this structure dynamically, ie, i want it to grow. It sounds to me like what you want isn't that the structure itself grow, but that you have an expandable array of those structures. [ ... ] > i want to grow the structure dynamically, ie, the valur of MAX is > provided at runtime. You could do that with something like: typedef struct my_time { int date; int hour; int minutes; } my_time; std::vector<my_time> some_times(MAX); -- Later, Jerry. The universe is a figment of its own imagination.
From: Nicky on 27 Sep 2006 00:35 > Your names (tm and time) are both _very_ poorly chosen. The standard > library already defines both of these. my actual structure is typedef struct tagITEMINFO { DWORD dwFileAttributes; CString strFileName; DWORD nFileSizeLow; FILETIME ftLastWriteTime; } ITEMINFO; BOOL CDataSync::AddItem(WIN32_FIND_DATA* pfd) { CListCtrl* pList = (CListCtrl*)GetDlgItem(IDC_LIST_CLIENT); ITEMINFO* pItem; pItem = new ITEMINFO; //Initialize pItem from pfd pItem->dwFileAttributes = pfd->dwFileAttributes; pItem->strFileName = pfd->cFileName; pItem->nFileSizeLow = pfd->nFileSizeLow; pItem->ftLastWriteTime = pfd->ftLastWriteTime; } this is with one file, i want to save information about n number of files. the function AddItem is called in some other function. what i require is tht when i call AddItem, the attributes for one object is stored in a buffer when when this function is called again, the buffer adds another object and so on.
From: Nicky on 27 Sep 2006 00:35 > Your names (tm and time) are both _very_ poorly chosen. The standard > library already defines both of these. my actual structure is typedef struct tagITEMINFO { DWORD dwFileAttributes; CString strFileName; DWORD nFileSizeLow; FILETIME ftLastWriteTime; } ITEMINFO; BOOL CDataSync::AddItem(WIN32_FIND_DATA* pfd) { CListCtrl* pList = (CListCtrl*)GetDlgItem(IDC_LIST_CLIENT); ITEMINFO* pItem; pItem = new ITEMINFO; //Initialize pItem from pfd pItem->dwFileAttributes = pfd->dwFileAttributes; pItem->strFileName = pfd->cFileName; pItem->nFileSizeLow = pfd->nFileSizeLow; pItem->ftLastWriteTime = pfd->ftLastWriteTime; } this is with one file, i want to save information about n number of files. the function AddItem is called in some other function. what i require is tht when i call AddItem, the attributes for one object is stored in a buffer when when this function is called again, the buffer adds another object and so on.
From: Nicky on 27 Sep 2006 00:36
> Your names (tm and time) are both _very_ poorly chosen. The standard > library already defines both of these. my actual structure is typedef struct tagITEMINFO { DWORD dwFileAttributes; CString strFileName; DWORD nFileSizeLow; FILETIME ftLastWriteTime; } ITEMINFO; BOOL CDataSync::AddItem(WIN32_FIND_DATA* pfd) { CListCtrl* pList = (CListCtrl*)GetDlgItem(IDC_LIST_CLIENT); ITEMINFO* pItem; pItem = new ITEMINFO; //Initialize pItem from pfd pItem->dwFileAttributes = pfd->dwFileAttributes; pItem->strFileName = pfd->cFileName; pItem->nFileSizeLow = pfd->nFileSizeLow; pItem->ftLastWriteTime = pfd->ftLastWriteTime; } this is with one file, i want to save information about n number of files. the function AddItem is called in some other function. what i require is tht when i call AddItem, the attributes for one object is stored in a buffer when when this function is called again, the buffer adds another object and so on. |