Question: C++ Help Make an array of structs (sounds like a project idea). You are going to create an array of basicStruct of size 10. You

C++ Help

Make an array of structs (sounds like a project idea).

You are going to create an array of basicStruct of size 10. You will then make a function with the following signature:

You are going to write one function called:

void readData( string input, string output ); 

declare it in:

lab9.h 

I would make it the last declaration in the file. So have the struct first, then this one.

This function will read data and store it in the array. The array this time is an array of the basicStruct type instead of ints, so our input will a string and a double. You are to read the string and the double. If there is space in the array, then store the string and the double in the array at the next available location in the array.

Sample Input

Dave 10.3 Kelly 15.2 Sue 45.5 Michael 36.5 Matt 23.1 Molly 7.25 

Sample Output

You should not initialize your array and then print out ?'s Just print out the values in the array.

I used ? above to represent the value that I don't know. Since those locations didn't get a value C++ doesn't guarantee any value. I will check that the good values are set.

Index Name Number 0 Dave 10.3 1 Kelly 15.2 2 Sue 45.5 3 Michael 36.5 4 Matt 23.1 5 Molly 7.25 6 ? ? 7 ? ? 8 ? ? 9 ? ? 

Testing

It's always a good idea to test your code. I'll provide a real simple main you can use.

#include  #include "lab9.h" using std::cout; using std::cin; using std::endl; int main() { readData( "input.txt", "output.txt"); } 

The output here will depend on what you type in the file. I would enter some data and see what happens.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!