Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.

stl getline question

This topic is 5588 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have the following piece of code:
	std::vector vec1;
	std::string line;

	ifstream infile("textfile.txt");

	while (std::getline(infile,line,''\n'')) {
		vec1.push_back (line);
For some reason I get the following compiler error: error C2784: ''class std::basic_istream<_E,_Tr> &__cdecl std::getline(class std::basic_istream<_E,_Tr> &,class std::basic_string<_E,_Tr,_A> &,const _E)'' : could not deduce template argument for ''class std::basic_istream<_E,_Tr> &'' from ''class ifstream'' Anyone have any ideas ? If I take away the std:: reference for getline, I get the error: error C2065: ''getline'' : undeclared identifier Nitzan ------------------------- www.geocities.com/nitzanw www.scorchedearth3d.net -------------------------

Share this post

Link to post
Share on other sites
You need to include some missing declarings.

#include <iostream>
#include <vector>
#include <string>
using std::string;
#include <fstream>
using std::ifstream;

std::vector<string> stringData;
string theString;
ifstream inFile;
inFile.open("someFile.txt", ios::in);

while (std::getline(inFile, theString))


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!