Strings into Ints

This is a discussion on Strings into Ints within the C++ Programming forums, part of the General Programming Boards category; Hi! I have a quick question. I need to change some strings into ints. For example: string a = "5"; ...

  1. #1
    Unregistered
    Guest

    Exclamation Strings into Ints

    Hi!

    I have a quick question.

    I need to change some strings into ints.
    For example:

    string a = "5";
    int b = (int version of a);

    (b = 5);

    I think there's a function somewhere that helps me do that, but I don't remember the name of it.

    Does anyone remember it?
    If there isn't such a function, is there a way for me to do this?

    Thanks a lot!

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    int b = atoi ( a.c_str() );

    -Prelude
    My best code is written with the delete key.

  3. #3
    Unregistered
    Guest
    that's it!

    Thanks a lot!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to handle ints and strings when writing to file
    By agentsmith in forum C Programming
    Replies: 11
    Last Post: 04-23-2008, 05:44 AM
  2. Array of Ints to a Strings
    By mattAU in forum C Programming
    Replies: 10
    Last Post: 08-17-2006, 06:25 AM
  3. writing strings chars from ints
    By deleeuw in forum C++ Programming
    Replies: 20
    Last Post: 08-19-2003, 10:09 AM
  4. converting strings to ints
    By HomerJ in forum C++ Programming
    Replies: 3
    Last Post: 04-25-2002, 07:08 PM
  5. Converting strings to ints
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 04-25-2002, 03:48 PM

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