Created
June 7, 2013 22:51
-
-
Save blaquee/5732955 to your computer and use it in GitHub Desktop.
test2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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