Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

converting ansistring to int

  • 15-04-2003 08:39PM
    #1
    Registered Users, Registered Users 2 Posts: 2,592 ✭✭✭


    i have this piece of code to take a value from an inputbox then convert it to an int then assign to a structure but it keeps telling me that i have clled an undefined function even thoughj i have included the vcl\dstring.h header file

    value is declared as an int

    AnsiString InputString = InputBox("Input Box", "Please enter the value for the gate", "0");
    value = ToIntDef(InputString);
    newconnector->Value = value;
    could any one help??

    tanx


Comments

  • Closed Accounts Posts: 3,322 ✭✭✭Repli


    try
    int value = ToIntDef(InputString);


  • Registered Users, Registered Users 2 Posts: 2,592 ✭✭✭tommycahir


    sorry repli still getting the same error
    tanx for trying


  • Closed Accounts Posts: 3,322 ✭✭✭Repli


    Hmm k.. Try
    int value = InputString.ToIntDef(-1);
    This does the same thing iirc except if it tries to convert a string to an int it will return -1


  • Registered Users, Registered Users 2 Posts: 6,240 ✭✭✭hussey


    int convert_ansi_int(AnsiString str) 
    {
    
    return atoi(str.c_str());
    
    }
    
    // this is equililebt of this (  I think)
    int convert_ansi_int(AnsiString str) 
    {
    
    char * tempStr = str.c_str();
    int num = atoi(tempStr);
    return num;
    
    }
    


Advertisement