it SHOULD be easy

This is a discussion on it SHOULD be easy within the C++ Programming forums, part of the General Programming Boards category; I want to convert a string(not a char array, an element of a string array) to a short( but an ...

  1. #1
    Unregistered
    Guest

    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
    Posts
    101
    basic_string<>::c_str() returns the C-style string you need:
    Code:
    string my_string = "1234";
    int my_int = atoi(my_string.c_str());
    - lmov

  3. #3
    Unregistered
    Guest
    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, 09: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, 04:56 AM
  4. Easy question, (should be) easy answer... ;-)
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 06-12-2002, 10:36 PM
  5. Replies: 20
    Last Post: 05-25-2002, 08:14 PM

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