Created
June 7, 2013 22:58
-
-
Save blaquee/5732986 to your computer and use it in GitHub Desktop.
Final Test
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[]) | |
{ | |
/////////---------Setting our path-------////////// | |
char link_path[MAXPATHLEN]; | |
char path[MAXPATHLEN]; | |
uint32_t size = sizeof(path); | |
if(_NSGetExecutablePath(path,&size) == 0) | |
{ | |
realpath(path, link_path); | |
std::cout << "The path is: " << link_path << std::endl; | |
} | |
else | |
{ | |
std::cout << "Could not fix the path stuff, I suck.." << std::endl; | |
} | |
/////////---------Setting path done-------////////// | |
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