istreambuf_iterator STL question

hi everybody . please help me

1
2
3
4
5
freopen("in.txt", "r", stdin);

deque<char> dq;
copy(istreambuf_iterator<char>(cin), istreambuf_iterator<char>(),
	back_inserter(dq));


and in.txt is :

95.123 12
0.43 20
5.1234 10
6.759 25
98.999 2
1.0 3

i want change this code read until ' ' charactor ! for example in first copy function dq become 95.123 . sorry for my bad eng language !
note : i want dq be char because it be big number !
Last edited on
Normally you would use getline(stream, string, ' ') for that, or some other stream parsing method.

But you could do with input iterators of course, as long as your algorithm is single-pass:

1
2
3
4
5
6
    ifstream fin("in.txt"); // why freopen?
    deque<char> dq;

    istreambuf_iterator<char> i(fin), end;
    while(i != end && *i != ' ')
        dq.push_back(*i++);
my dear i want use copy function !! i think i must define my char_traits and change eof type and send it to template argument of istreambuf_iterator
Topic archived. No new replies allowed.