×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

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

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

(OP)
how would i edit the following code to read from the TEdit box, Edit1, and print to the Memo box Memo1.

#include <iostream.h>
#include <fstream.h>
#include <string.h>

char num[10];
char roomdesc[501];
char dir[100];
int main()
{
cout << "Welcome" << endl;
do {
cout << "Please select (1-10) : ";
switch (dir)
{
case 1 :
{
strcpy(race, "One");
break;
}
case 2 :
{
strcpy(race, "Two");
break;
}
case 3 :
{
strcpy(race, "Three");
break;
}
case 4 :
{
strcpy(race, "Four");
break;
}
case 5 :
{
strcpy(num, "Five");
break;
}
case 6 :
{
strcpy(num, "six");
break;
}
case 7 :
{
strcpy(num, "seven");
break;
}
case 8 :
{
strcpy(num, "eight");
break;
}
case 9 :
{
strcpy(num, "nine");
break;
}
case 10 :
{
strcpy(num, "ten");
break;
}
default :
{
}
}
While(dir!=exit);
return 0;
}

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

    OK, I assumming that you are using Edit1 as a replacement for cin and Memo1 for cout.

// cout << "Welcome" << endl;
Memo1->Lines->Add("Welcome");

//cout << "Please select (1-10) : ";
Memo1->Lines->Add("Please select (1-10)");

// cin >> dir; I didn't see this so I am assumming it
// char dir[100]
AnsiString dir = Edit1->Text; //AnsiString is Borland's Delphi version of C++ strings

    You could still use the character arrays but I find using strings easier. It also lets you eliminate strcpy.
// I didn't see where you defined race or num
AnsiString race, num;
.
.
.
race = "One";
.
.
.
num = "Five";

James P. Cottingham

International Veneer Co., Inc.
All opinions are mine alone and do not necessarily reflect those of my employer.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close