Skip to content

Instantly share code, notes, and snippets.

@blaquee
Created June 7, 2013 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blaquee/5732955 to your computer and use it in GitHub Desktop.
Save blaquee/5732955 to your computer and use it in GitHub Desktop.
test2
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <iterator>
#include <unistd.h>
#include <sys/param.h>
//#include <mach-o/dyld.h>
int main(int argc, const char * argv[]){
char buf[MAXPATHLEN];
size_t size = sizeof(buf);
//no error checking for this purpose.
getcwd(buf,size);
std::cout << "The current working directory is: " << buf << std::endl;
std::ifstream in("testfile.txt");
std::vector<std::string> vec;
if(in){
std::string s;
while(std::getline(in, s))
{
vec.push_back(s);
//print each line to output stream
std::ostream_iterator<std::string> out(std::cout,"\n");
std::copy( vec.begin(), vec.end(), out );
}
}
else
{
std::cout << "file open error" << std::endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment