Skip to content

Instantly share code, notes, and snippets.

@blaquee
Created June 7, 2013 22:58
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/5732986 to your computer and use it in GitHub Desktop.
Save blaquee/5732986 to your computer and use it in GitHub Desktop.
Final Test
#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,&amp;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