everybody I've been running into this problem with my homework for awhile. I tried to get help but was answered with "I can't help". The assignment is to parse a file and calculate the given shapes perimeter or area. Here is what I have so far:
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
using namespace std;
vector<string> parseString(string); // prototype
int main()
{
ifstream fin;
string str;
fin.open("Shapes.input.txt");
while(!fin.eof())
{
std::getline(fin,str);
vector<string> tokens = parseString(str);
cout << tokens[0];
}
fin.close();
}
vector<string> parseString(string str)
{
stringstream s(str);
istream_iterator<string> begin(s), end;
return vector<string>(begin, end);
}
The code will successfully build but I get an error for: EXC_BAD_ACCESS. I am not sure how to debug this. I will include the data I made in the file as well to test this portion.
SQUARE 5 SQUARE 7
Sorry if this is a lengthy post, it is my first time posting and I would appreciate any help.