-
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
-
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.
-
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 :)
-
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
-
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;
}