avr39-ripe

pollIntFloat QUIZZZ

Apr 15th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. int main()
  2. {
  3.     uint8_t* pool;
  4.     pool = createPool(pool, 5);
  5.     poolElement(pool, 0, 1);
  6.     poolElement(pool, 1, 2.2f);
  7.     poolElement(pool, 2, 3.3f);
  8.     poolElement(pool, 3, 4.4f);
  9.     poolElement(pool, 4, 5);
  10.  
  11.     for (int i = 0; i < 5; i++) { cout << elementTypeAt(pool, i) << " ";  printElementAt(pool, i); };
  12.  
  13.     elementAsFloatAt(pool, 3) = 6.6f;
  14.     elementAsIntAt(pool, 4) = 2607;
  15.     poolElement(pool, 0, 11.11f);
  16.  
  17.     for (int i = 0; i < 5; i++)
  18.     {
  19.         char typeId = elementTypeAt(pool, i);
  20.         if (typeId == 'i') { cout << elementAsIntAt(pool, i) << endl; };
  21.         if (typeId == 'f') { cout << elementAsFloatAt(pool, i) << endl; };
  22.     };
  23.  
  24.     deletePool(pool);
  25. }
  26.  
  27. //On the screen
  28. i 1
  29. f 2.2
  30. f 3.3
  31. f 4.4
  32. i 5
  33. 11.11
  34. 2.2
  35. 3.3
  36. 6.6
  37. 2607
Advertisement
Add Comment
Please, Sign In to add comment