Guest User

Untitled

a guest
Mar 22nd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. public static void UseParams(params int[] list) {
  2. for (int i = 0; i < list.Length; i++) {
  3. Console.Write(list[i] + " ");
  4. }
  5. Console.WriteLine();
  6. }
  7. UseParams(1, 2, 3, 4); // UseParams(int ..........)
  8.  
  9. void updateJsonArray_INA(INA3221DATA _channel1, INA3221DATA _channel2, INA3221DATA _channel3) {
  10.  
  11. }
  12.  
  13. void updateJsonArray_INA(INA3221DATA _channel1, _channel2, _channel3) {
  14.  
  15. }
  16.  
  17. #include <stdio.h>
  18. #include <stdarg.h>
  19.  
  20. void use_params(int number_of_params, ...) {
  21. va_list args;
  22. va_start(args, number_of_params);
  23.  
  24. for(int i = 0; i < number_of_params; ++i) {
  25. some_type element = va_arg(args, some_type);
  26. do_something_with(element);
  27. }
  28.  
  29. va_end(args);
  30. }
  31.  
  32. void main() {
  33. use_params(4, 'a', 'b', 'c', 'd');
  34. }
  35.  
  36. #include <stdio.h>
  37. #include <stdarg.h>
  38.  
  39. void use_params(const std::vector<int>& params) {
  40. for(size_t i = 0; i < params.size(); ++i) {
  41. do_something_with(params[i]);
  42. }
  43. }
  44.  
  45. void main() {
  46. use_params({1, 2, 3, 5});
  47. }
Add Comment
Please, Sign In to add comment