Thread: Convert from string to int.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    There is no such keyword (other than new, new[], and the making of the variable into a global or member variable, but I suspect those are not what you are looking for here).

    One option is to return a value from the function, and then call that function from the other function. You might want to read a tutorial on functions, say the one at cprogramming.com
    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. #2
    Registered User
    Join Date
    May 2007
    Posts
    12
    what i want to do is create an integer array.

    but i don't know what size it will be until i have ran other functions within the class.

    All I want to do is create the integer array inside say function1 and have it available to other functions when function1 has finished...

    Basically my app reads a text file and discovers how many cd objects are in the text file, and then creates an int array of that size. Ie 4 cd's = int container[3]

    Then a different function re-reads the file to determine how many tracks there are for each cd and then puts them in.
    For example, if container[2] contained the value 6 - that would mean there were 6 tracks on cd 3.

    But for this to work , I need Container[] to be available to both functions. Can't create it at the beginning because I'll only know how big it should be after function 1 is ran...



    Alternatively maybe sort of declare the int array as a global at the top but not set the size of it until midway?
    possible? not?
    Last edited by LeighRogers; 05-09-2007 at 01:56 PM.

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, 08: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-02-2003, 12:26 AM