I have this assignment where I'm supposed to read in a text file and assign the values to a vector and sort them out. The text file has values for country, population, birth rate, and death rate.

An example is: (not realistic numbers)
USA 400000 5400 3200
Canada 56000 3400 2300
Mexico 38000 2600 5400

the second row should be assigned to population, third birth rate, and fourth death rate, but I don't know how to start it off :(. Any help would be appreciated!

Recommended Answers

All 3 Replies

Here's a good starting point.

#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
	return 0;
}

I don't know how to make declarations for country, population, birth rate and death rate from reading a file. Also, storing these into a vector.

Well if I was responsible for this I would:

1. Create a data structure to hold my data - country, population, birth rate and death rate.
2. Create a vector with my data structure as its type.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.