data storage

This is a discussion on data storage within the C++ Programming forums, part of the General Programming Boards category; Hi all.. I'm pretty new to the c++ game and i'm getting a good understanding of it. I need some ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    1

    Exclamation data storage

    Hi all.. I'm pretty new to the c++ game and i'm getting a good understanding of it. I need some help though. For one program i'm writing, i need to store and retrieve a set of numbers (used as sales for a given week) and display them through an array. In qbasic which I have been using for a while, there is the simple DATA statement which i could READ at any time in the program. Does c++ have a similar stucture where i can declare data statements in the program and read them into an array? Any help would be appreciated, thanks

    -Simon

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    155
    streams and loops can be used to do what you want, but maybe not in quite the same fashion as with QBasic. Streams have a variety of methods/operators to assist you.

  3. #3
    Unregistered
    Guest
    ya can we get an example going here perhaps? I'm having the same problem to get data from somewhere for use in calculations and could really use a sample or what i should specifically look up to learn in order to be able to do it.. thanks a bunch

  4. #4
    Unregistered
    Guest
    how about just a way to intialize the arrays with the variables already in them? is it possible to do that with strings, i know i can do it with numbers already

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Here's character array initialization.
    Code:
    int main()
    {
       char *cars[20] = {"Camry", "Sentra", "Cutlass", "Camaro", "Firebird",
       "Mustang", "Corvette","Impala", "LeSabre", "Neon",
       "Viper", "Beetle", "Le Sabre", "Cougar","Thunderbird",
       "Coup de Ville", "Miata", "Taurus", "Jaguar", "Porche"};
    
       for (i=0; i<20; i++)
          cout << cars[i] << endl;
       return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. data structure design for data aggregation
    By George2 in forum C# Programming
    Replies: 0
    Last Post: 05-20-2008, 07:43 AM
  2. question about a working linked list
    By cold_dog in forum C++ Programming
    Replies: 23
    Last Post: 09-13-2006, 02:00 AM
  3. Reading a file with Courier New characters
    By Noam in forum C Programming
    Replies: 3
    Last Post: 07-07-2006, 10:29 AM
  4. All u wanted to know about data types&more
    By SAMSAM in forum Windows Programming
    Replies: 6
    Last Post: 03-11-2003, 03:22 PM
  5. C Programming Question
    By TK in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 07-04-2002, 08:11 PM

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