char array/AnsiString problem...

This is a discussion on char array/AnsiString problem... within the Windows Programming forums, part of the Platform Specific Boards category; Hi everyone, this is my first post on that forum, I hope I'll find the answers to my questions here! ...

  1. #1
    Registered User V1P3R V3N0M's Avatar
    Join Date
    Jan 2003
    Posts
    22

    char array/AnsiString problem...

    Hi everyone, this is my first post on that forum, I hope I'll find the answers to my questions here!

    I've already programmed in DOS and Shell but never did with Borland Builder (Windows GUI) so I'm new to some details in syntax and how to get information from built-in objects...

    My problem is that I've coded a little function that sorts an int array with a kinda weird algorithm (anyway!)... So I have 9 boxes to enter the integers not sorted and I have a button, then 9 other boxes where I can see the result from the first 9 boxes.

    I had a little problem when I had to take what I wrote in Edit1.Text (TEdit) and then put it in a char array (I want to stock the data before converting it to an integer value).

    Here's the problematic line (with the var definitions), you don't need anything else to give me the answer since the problem is only a difference between the TEdit.Text datatype and the char * datatype.

    Code:
      int Array[9];
      char Temp[10];
      strcpy(Temp, Edit1->Text);
    Someone told me there was something like "Edit1->Text.toString()" but I'm really not sure about it, I tried and it gave nothing... So what should I do to put that AnsiString value into my char array???

    Thanks for replies!!

    V1P3R V3N0M
    v1p3r_v3n0m@yahoo.com

    BTW; why is Salem so against the use of "void main()"???

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    ... probably do better on the Windows board, as it's a GUI kinda question.

    >>why is Salem so against the use of "void main()"???
    Do a search and find like a thousand posts on this topic Basically, its non-standard and should be avoid whereever possible. Enough said on that though.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User V1P3R V3N0M's Avatar
    Join Date
    Jan 2003
    Posts
    22
    huh

    thx for not responding to my question all of you who are supposed to know gui programming!!! :P

    Code:
      int Array[9];
      char Temp[10];
      strcpy(Temp, Edit1->Text.c_str());

    found it myself

    vprvnm

  4. #4
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    >thx for not responding to my question...

    Wrote the stuff below for you before I saw your last post.

    >all of you who are supposed to know gui programming!!!

    That's a little harsh. The problem is that AnsiString (along with other VCL classes) are Borland specific. [Unfortunately] most people here don't use Borland C++ Builder.


    >strcpy(Temp, Edit1->Text);

    This is not a problem. Do the following:

    strcpy(Temp, Edit1->Text.c_str());

    The c_str() returns a pointer to a char array maintained by the AnsiString object.

    AnsiStrings are objects, and are similar to the standard library string object. Use the Borland help system to see other useful methods supported by AnsiString.
    OS: Windows XP
    Compilers: MinGW (Code::Blocks), BCB 5

    BigAngryDog.com

  5. #5
    Registered User V1P3R V3N0M's Avatar
    Join Date
    Jan 2003
    Posts
    22
    cool, thx! just what I posted.. in fact

    but someone who knew the answer and took the time to reply to me.. thx a lot

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding info in a header file
    By hicpics in forum C Programming
    Replies: 8
    Last Post: 12-02-2005, 12:36 PM
  2. char problem
    By ForlornOdium in forum C++ Programming
    Replies: 10
    Last Post: 10-29-2003, 02:39 PM
  3. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 05:10 PM
  4. String Processing Problem
    By muffin in forum C Programming
    Replies: 0
    Last Post: 08-24-2001, 11:13 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21