Convert from string to int.

This is a discussion on Convert from string to int. within the C++ Programming forums, part of the General Programming Boards category; I suggest reaching for a std::vector<int>. You can then also return it from the function, or, if appropriate, it might ...

  1. #16
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,614
    I suggest reaching for a std::vector<int>. You can then also return it from the function, or, if appropriate, it might be more suitable as a member variable instead. The alternative does involve new[], but I would not use it unless I really have to.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  2. #17
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Pass an address of a struct (or class) allocated on the heap around then, (as a function arg)

  3. #18
    Registered User
    Join Date
    May 2007
    Posts
    12
    Thank you for your suggestions :-)

    I eventually solved it by creating an int pointer.

    ie
    Code:
    int * temp;
    then further down just said
    Code:
    temp = new int[value];
    Thanks for your help - my assignment (a media player) is almost now complete, got some bugs in it that I'm struggling with but i'll start another thread :-)

    Thanks again!
    Leigh

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to combine these working parts??
    By transgalactic2 in forum C Programming
    Replies: 0
    Last Post: 02-01-2009, 07:19 AM
  2. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  3. Debug Error Really Quick Question
    By GCNDoug in forum C Programming
    Replies: 1
    Last Post: 04-23-2007, 12:05 PM
  4. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM
  5. Quack! It doesn't work! >.<
    By *Michelle* in forum C++ Programming
    Replies: 8
    Last Post: 03-01-2003, 11:26 PM

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