Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

C++ Builder

Posted on 1999-01-16
13
Medium Priority
?
316 Views
Last Modified: 2010-04-16
I am writing a program in C++ Builder.  I'm using the string ADT and a Memo component.  I'm trying to do the following:

  string TempPalindrome;
  TempPalindrome = MemoPalindromeCandidates->Lines[1];

This is not working because Lines is of type TStrings.  I need something that is compatible with the string ADT.  For example and AnsiString would be compatible:

//This works okay.
string TempPalindromeFile;
TempPalindromeFile = openDlg->FileName.c_str();

Because FileName is an AnsiString, you can add c_str() on the end and assign the whole thing to TempPalindromeFile.

Thanks.

0
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
13 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1184379
Hello KnowIton :)

How is the game editor going?

When did you decide to use C++ Builder?

Ok, here is how you do that in C++ Builder...

String TempPalindrome;
TempPalindrome = MemoPalindromeCandidates->Lines->Strings[1];
ShowMessage(TempPalindrome);

or you could simply do this...

ShowMessage(MemoPalindromeCandidates->Lines->Strings[1]);

This is just an example... Let me know if you need more help :)

-Viktor
--Ivanov
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 1184380
Viktornet:

This works in Delphi, I'm sure...but this is C++ Builder.  I'm using the string Abstract Data Type.  It is not the same "string" type as the one in Delphi.

Your code example will definitely not work in C++ Builder.

Do you actually HAVE C++ Builder?  I'm wondering.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1184381
Yes I do have C++ Builder....

Have you tried what I gave you?

Here is what I've tested with C++ Builder and it works perfectly...

String str;

str = Memo1->Lines->Strings[0];

ShowMessage(str);

and it displays Memo1 because that's what I have in the first line in the Memo, so I think my answer was correct...

-Viktor
--Ivanov
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 10

Expert Comment

by:viktornet
ID: 1184382
In Delphi you can do Str := Memo1.Lines[0]; but that's not the case in the Builder... In C++ Buil;der you should include the full thing as Str = Memo1->Lines->Strings[0]; The same thing can be used in Delphi... Did you actually try the code? If not you better try before rejecting... If I misunderstood something, than I apologize for that,....
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 1184383
Viktornet:

Actually...you are correct.  Just one minor change to your solution is necessary:

String TempPalindrome;
TempPalindrome = MemoPalindromeCandidates->Lines->Strings[1].c_str();

The   .c_str()   is necessary to convert the Strings[1] over to the string ADT.

Thanks for your help!

Please repost your question as an answer and I will give you your points.

As for why I am using C++ Builder...well, it's not exactly by choice.  The class I'm taking in Object Oriented Data Structures requires everything be written in C++.  Since I prefer Windows apps...C++ Builder seemed a logical choice.

The MYST clone is going so so.  I'm mostly doing design work right now.  

Talk to you later,

Tom


0
 
LVL 10

Accepted Solution

by:
viktornet earned 60 total points
ID: 1184384
What exactly is an ADT type of string?? Is it a pointer to a character?? because that's what c_str() returns?!?!....

you can do this...

String str;

str = Memo1->Lines->Strings[0];

or you copuld do this....

char *str = Memo1->Lines->Strings[0].c_str();

Well, either way... If you need more help let me know...

-Viktor
--Ivanov
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 1184385
Here you go.

Thanks!
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1184386
You mad at me for something or what? Why don't you talk a lot? And would you please tell me what an ADT type is? Thanks!
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1184387
Oh and why did you give me a B? Anything wrong with my answer? I was just trying to help...
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 1184388
I don't remember what happened with this?

I don't know why I gave you a B.

Refresh my memory.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1184389
never mind...
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 1184390
Viktor:

I posted a question on "Drag and Drop" in the C++ section.  Have you done this type of thing?
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1184391
Hello Tom!!

I just read your question... I've not tried doing such a thing, but I might try soon, and if I succeed I will let you know... It's kinda hard since I dont have much time, but if i find some spare time I will try to do that...

..-=ViKtOr=-..
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question