#include <iostream>
#include <string>
#include <fstream>
int main()
{
usingnamespace std;
ifstream file("projeto1.txt");
if (file.is_open())
{
string myArray[5];
for (int i = 0; i < 5; ++i)
{
file >> myArray[i];
cout << myArray[i] << endl;
}
}
}
Now there are two things that I want to know.
First the text file will vary and by so the position of a certain string will also vary so how can I save a specific part of the text file?
Second in my for cicle how should I go about putting the number of word into it (i < number_of_words ) should I just put a huge number? but that would be bad for the machine i guess...
First the text file will vary and by so the position of a certain string will also vary so how can I save a specific part of the text file?
Without seeing a small sample of your text file and you being more specific as to what you're trying to accomplish it would only be guess work to answer this question.
Second in my for cicle how should I go about putting the number of word into it (i < number_of_words ) should I just put a huge number?
Well instead of using an array I suggest you use a vector and instead of a for loop just insert all the strings into the vector.
and now I want to get all those expenses values (300,50,100,.....) and do the sum . I would also like to get the title and the company name, the thing is the company name will vary hence my first question..