Click here to Skip to main content
13,004,421 members (74,294 online)
Rate this:
Please Sign up or sign in to vote.
See more:

i'm trying to update a program that printed results to a DOS window to a text box in Visual C++ 2010

Posted 11-Oct-12 7:03am
Sergey Alexandrovich Kryukov 11-Oct-12 14:17pm
No, you don't have a problem printing anything to a DOS window. If you are using Visual Studio 2010, it can only run on systems which don't have a "DOS window"!
Wes Aday 11-Oct-12 14:25pm
Thanks for keeping us up to date on your progress. Please let us know if you have an actual question related to a specific programming problem.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Well, first of all, please see my comment to the question.

Replace the function printf with sprintf which "prints" to a string:[^].

You can even avoid replacing the function name where it is currently used. Instead, wrap a call to sprintf into a function and name it printf; use this new function in your legacy code.

When all printing to a string is done, use this string to populate the text box value.

CPallini 11-Oct-12 15:34pm
My 5. However you probably overlooked the additional parameter of sprintf while suggesting the OP to replace printf in the legacy code (or maybe I didn't get you).
Sergey Alexandrovich Kryukov 11-Oct-12 15:48pm
Thank you very much.

Yes, you are exactly right about this string parameter.
Well, no, I actually though about it, just left to the OP, as it could be worked around. Perhaps, I assumed too much about OP's ability to resolve it.
One way I can see to make it an instance property of some class, encapsulate the function with the class where it is used. In this case, the pointer to the string could be accessed through the "this" parameter of the "imitation printf" method.

Maybe, just changing the function name and adding the parameter throughout the code could be easier. It depends on the legacy code. I also don't know if the previously developed functionality writing in console should still be supported or not.

I hope it explains the approach to be used now.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

hi dear john

you have to do these :

we have a text(edit control) box and it named t.
write these code into a button to perform that.
CString s;
char *a=0;
s=_T("echo ")+s+_T("\n pause");

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170627.1 | Last Updated 11 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100