Alternatives to sprintf?
I remember reading something on the web that you can use cout as an alternative to sprintf. I just can''t remember where I read it. My problem is:
Example:
char buffer[20];
sprintf(buffer, " %d", 50);
TextOut(hdc, 10, 10, buffer, strlen(buffer));
From what I remember you can do something like this:
char buffer[20];
cout << 50 << buffer;
TextOut(hdc, 10, 10, buffer, strlen(buffer));
But it doesn''t seem to work, can someone tell me what I am doing wrong?
Jeff
I wouldn''t have thought you could do this. You could use ostringstream. I think this should work (I''m not certain: I haven''t got C++ nearby to test it.)
All your bases belong to us (I know. It''s irony.)
ostringstream buffer(); buffer << 50; TextOut(hdc, 10, 10, (LPCTSTR) buffer.str().c_str(), (int) buffer.str().length());
All your bases belong to us (I know. It''s irony.)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement