Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello

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


Regards,
Binu
Posted
Comments
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"!
--SA
[no name] 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.

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

Replace the function printf with sprintf which "prints" to a string:
http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/[^].

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.

—SA
 
Share this answer
 
Comments
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.
--SA
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;
USES_CONVERSION;
t.GetWindowText(s);
s=_T("echo ")+s+_T("\n pause");
a=T2A(s.GetBuffer());
system(a);
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900