I don't want a whole program written for me, I just need some tips or what type of loops I should use, or if I should even use any loops at all. Thanks!
So I am trying to create a program that will display different sets of data. I will be getting the sets of data by importing the file by using linux redirection. The issue I am having is how to go about displaying the sets of data and how to get the data from the file.
I can't think of a way to do it. I understand a loop will have to be used however I don't know much about loops to understand how to display different sets of data for each loop and how I can collect them.
I will receive, at the beginning of the file how many sets of data I will have to display and each set of data will be different from the last, so how would I go about doing this without writing five hundred different statments to display random sets of data and 500 cin statements to collect the actual sets of data.
I hope I was clear if I wasn't please ask for me to be more clear because I truly do need help.
redirection is done via command line, take the following code:
1 2 3 4 5 6 7 8 9 10
#include <iostream>
#include <string>
int main(void)
{
std::string word;
std::cin >> word;
std::cout << word << std::endl;
return 0;
}
Compiled as "wordcopy", redirect via command line:
1 2 3 4
$ wordcopy // cin and cout are from/to console
$ wordcopy >output.txt // cin is from console, cout is to "output.txt"
$ wordcopy <input.txt // cin is from "input.txt", cout is to console
$ wordcopy <input.txt >output.txt // cin and cout are from/to files
enhancing the program to use a set of data printed/read to/from file:
Can you please explain that more in depth for me please? I want to understand what I am writing. The string word; at the top what is that for? I am using numbers also, it is one line of data however their are multiple parts that need to be used I have to separate out the data myself. Would the code that you used above help do that???