Guest User

Untitled

a guest
Jan 18th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. struct Thing{
  2. char *stuff;
  3. char **morestuff;
  4. int evenmorestuff;
  5. };
  6.  
  7. Thing *thingarray;
  8. thingarray = malloc(sizeof(Thing));
  9.  
  10. ....
  11.  
  12. //And then allocating space for elements, which will get called an unknown amount of times
  13. Thing j;
  14. thingarray[count] = j;
  15.  
  16. #include <vector>
  17. using namespace std;
  18.  
  19. struct Thing
  20. {
  21. char *stuff;
  22. char **morestuff;
  23. int evenmorestuff;
  24. };
  25.  
  26. int _tmain(int argc, _TCHAR* argv[])
  27. {
  28. vector<Thing> vt;
  29.  
  30. char stuff = 'a';
  31. char *morestuff = "abc";
  32.  
  33. Thing t;
  34. t.stuff = &stuff;
  35. t.morestuff = &morestuff;
  36. t.evenmorestuff = 0;
  37.  
  38. int count = 10;
  39. for (int i = 0; i <= count; ++i)
  40. {
  41. t.evenmorestuff = i;
  42. vt.push_back(t);
  43. }
  44.  
  45. Thing j;
  46. j.stuff = &stuff;
  47. j.morestuff = &morestuff;
  48. j.evenmorestuff = 0;
  49.  
  50. vt[count] = j;
  51.  
  52. return 0;
  53. }
Add Comment
Please, Sign In to add comment