You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 satır
828B

  1. /*
  2. * Use of ibufsteam to parse a line and obufstream to format a line
  3. */
  4. #include <SPI.h>
  5. #include "SdFat.h"
  6. #include "sdios.h"
  7. // create a serial output stream
  8. ArduinoOutStream cout(Serial);
  9. //------------------------------------------------------------------------------
  10. void setup() {
  11. char buf[20]; // buffer for formatted line
  12. int i, j, k; // values from parsed line
  13. Serial.begin(9600);
  14. // Wait for USB Serial
  15. while (!Serial) {
  16. SysCall::yield();
  17. }
  18. delay(2000);
  19. // initialize input string
  20. ibufstream bin("123 456 789");
  21. // parse the string "123 456 789"
  22. bin >> i >> j >> k;
  23. // initialize output buffer
  24. obufstream bout(buf, sizeof(buf));
  25. // format the output string
  26. bout << k << ',' << j << ',' << i << endl;
  27. // write the string to serial
  28. cout << buf;
  29. }
  30. void loop() {}