Thread: it SHOULD be easy

  1. #1

    it SHOULD be easy

    I want to convert a string(not a char array, an element of a string array) to a short( but an int is what I'm asking after)
    I cant seem to get CONVERT() or StrToInt to work,and atoi uses a string array. Unless of course, I use a multidimesional char array(how about no). I know this is in the faq, but that's atoi. Any suggestions? Possibly, code to convert char array to string?

  2. #2
    Registered User
    Join Date
    Aug 2001
    basic_string<>::c_str() returns the C-style string you need:
    string my_string = "1234";
    int my_int = atoi(my_string.c_str());
    - lmov

  3. #3
    That's it! Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Easy String position question...
    By Striph in forum C Programming
    Replies: 4
    Last Post: 05-11-2009, 08:48 PM
  2. Seg fault in easy, easy code
    By lisa1901 in forum C++ Programming
    Replies: 11
    Last Post: 12-10-2007, 05:28 AM
  3. Java vs C to make an OS
    By WOP in forum Tech Board
    Replies: 59
    Last Post: 05-27-2007, 03:56 AM
  4. Easy question, (should be) easy answer... ;-)
    By Unregistered in forum A Brief History of
    Replies: 1
    Last Post: 06-12-2002, 09:36 PM
  5. Replies: 20
    Last Post: 05-25-2002, 07:14 PM