Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing cin, cout, and other stuff into a form application program...

Status
Not open for further replies.

Aven

Programmer
Jun 8, 2000
3
0
0
US
how would i edit the following code to read from the TEdit box, Edit1, and print to the Memo box Memo1.<br><br>#include &lt;iostream.h&gt;<br>#include &lt;fstream.h&gt;<br>#include &lt;string.h&gt;<br><br>char num[10];<br>char roomdesc[501];<br>char dir[100];<br>int main()<br>{<br>cout &lt;&lt; &quot;Welcome&quot; &lt;&lt; endl;<br>do {<br>cout &lt;&lt; &quot;Please select (1-10) : &quot;;<br>switch (dir)<br>{<br>case 1 :<br>{<br>strcpy(race, &quot;One&quot;);<br>break;<br>}<br>case 2 :<br>{<br>strcpy(race, &quot;Two&quot;);<br>break;<br>}<br>case 3 :<br>{<br>strcpy(race, &quot;Three&quot;);<br>break;<br>}<br>case 4 :<br>{<br>strcpy(race, &quot;Four&quot;);<br>break;<br>}<br>case 5 :<br>{<br>strcpy(num, &quot;Five&quot;);<br>break;<br>}<br>case 6 :<br>{<br>strcpy(num, &quot;six&quot;);<br>break;<br>}<br>case 7 :<br>{<br>strcpy(num, &quot;seven&quot;);<br>break;<br>}<br>case 8 :<br>{<br>strcpy(num, &quot;eight&quot;);<br>break;<br>}<br>case 9 :<br>{<br>strcpy(num, &quot;nine&quot;);<br>break;<br>}<br>case 10 :<br>{<br>strcpy(num, &quot;ten&quot;);<br>break;<br>}<br>default :<br>{<br>}<br>}<br>While(dir!=exit);<br>return 0;<br>}
 
&nbsp;&nbsp;&nbsp;&nbsp;OK, I assumming that you are using Edit1 as a replacement for <i>cin</i> and Memo1 for <i>cout</i>.<br><br>// cout &lt;&lt; &quot;Welcome&quot; &lt;&lt; endl;<br>Memo1-&gt;Lines-&gt;Add(&quot;Welcome&quot;);<br><br>//cout &lt;&lt; &quot;Please select (1-10) : &quot;;<br>Memo1-&gt;Lines-&gt;Add(&quot;Please select (1-10)&quot;);<br><br>// cin &gt;&gt; dir; I didn't see this so I am assumming it<br>// char dir[100]<br>AnsiString dir = Edit1-&gt;Text; //AnsiString is Borland's Delphi version of C++ strings<br><br>&nbsp;&nbsp;&nbsp;&nbsp;You could still use the character arrays but I find using strings easier. It also lets you eliminate <i>strcpy</i>.<br>// I didn't see where you defined race or num<br>AnsiString race, num;<br>.<br>.<br>.<br>race = &quot;One&quot;;<br>.<br>.<br>.<br>num = &quot;Five&quot;;<br><br> <p>James P. Cottingham<br><a href=mailto: > </a><br><a href= Veneer Co., Inc.</a><br>All opinions are mine alone and do not necessarily reflect those of my employer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top