TITLE: Converting integers to ascii using streams PROBLEM: wenger@cis.ohio-state.edu (Rephael Wenger) The following program converts integers to text using the strstream class. Note the second time around I have to reset the buffer pointer and add a NULL character to terminate the string. The whole thing seems rather awkward. Is there a better way? [Repheal's code omitted...] RESPONSE: rmartin@thor.Rational.COM (Bob Martin), 16 Mar 93 Yes, try the following. Note the use of ends to put the NULL at the end of the string. #include #include void itob(char* buf, int n, int i) { ostrstream o(buf, n); o << i << ends; } void main() { char buf[20]; for (int i=0; i<10; i++) { itob(buf, 20, i); cout << buf << endl; } }