Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 8 months ago.
using iostream cin>> to enter strings with mbed, how to make a serial stream end?
when I send string to mbed board by pc COM port, the mbed serial stream can't terminate, in windows VC++ can make stream end by Ctrl-Z(Linux Ctrl-D) in command line, how to make an EOF to end the stream of serial in mbed?
istream_iterator
#include "mbed.h" #include <iostream> #include <vector> #include <string> #include <algorithm> using namespace std; DigitalOut myled(LED1); vector<string> sentence; int main() { copy(istream_iterator<string>(cin), istream_iterator<string>(), back_inserter(sentence)); copy(sentence.begin(), sentence.end(), ostream_iterator<string>(cout," ")); cout<<endl; }