- Aug 14, 2001
- 11,061
- 0
- 0
Well, it's been at least 4-5 years since I've even worked with some C++ programming, but I need to refresh in it right now. I had a couple of really ridiculously easy questions that I'm hoping that someone can help me out on that I've blanked on the syntax upon.
I have two made up input data files:
input1.dat with the following contents:
monkey 5.1
snail 7.2e-9
carrot 6.6
input2.dat with the following contents:
monkey 9.8
snail 4.2e-5
carrot -6.6
How would I step through each of the input files and obtain all of the names in a string array containing each name (monkey, snail, or carrot) in its own element so that later I can call up each name separately ie, I'm trying to get an array containing 'monkey' as the first index, 'snail' as the second index, and 'carrot' as the third index. After reading in the name, I would also need to read in the numerical value following the name into a separate variable array.
So, in the end, I'm trying to get array_name['monkey','snail','carrot'] and
input1values[5.1,7.2e-9,6.6] and input2values[9.8,4.2e-5,-6.6].
Thanks.
I have two made up input data files:
input1.dat with the following contents:
monkey 5.1
snail 7.2e-9
carrot 6.6
input2.dat with the following contents:
monkey 9.8
snail 4.2e-5
carrot -6.6
How would I step through each of the input files and obtain all of the names in a string array containing each name (monkey, snail, or carrot) in its own element so that later I can call up each name separately ie, I'm trying to get an array containing 'monkey' as the first index, 'snail' as the second index, and 'carrot' as the third index. After reading in the name, I would also need to read in the numerical value following the name into a separate variable array.
So, in the end, I'm trying to get array_name['monkey','snail','carrot'] and
input1values[5.1,7.2e-9,6.6] and input2values[9.8,4.2e-5,-6.6].
Thanks.