C++ C++;-Can';无法在XCode中打开文件

C++ C++;-Can';无法在XCode中打开文件,c++,xcode,file-io,C++,Xcode,File Io,我有一个main函数,它执行一些函数,特别是调用前面定义的两个函数: Student* readStudentsFromFile(string filename, int num) { ifstream studentsStream; studentsStream.open(filename.c_str()); if (!studentsStream.is_open()) { cerr << "Couldn't open the file " << filenam

我有一个main函数,它执行一些函数,特别是调用前面定义的两个函数:

Student* readStudentsFromFile(string filename, int num) {
ifstream studentsStream;
studentsStream.open(filename.c_str());
if (!studentsStream.is_open()) {
    cerr << "Couldn't open the file " << filename << endl;
    return NULL;
}
// create a new array of students with size 'num'
Student* students = new Student[num];
string name, school, sid;
int id;
// read student records from file
for (int i = 0; i < num; i++) {
    getline(studentsStream, name, ',');
    getline(studentsStream, sid, ',');
    getline(studentsStream, school);
    istringstream idConv(sid);
    idConv >> id;
    // create a student object from the record and store it in the array
    students[i] = Student(id, name, school);
}
studentsStream.close();
return students;
}
Student*readStudentsFromFile(字符串文件名,int-num){
ifstream学生流;
打开(filename.c_str());
如果(!studentsStream.is_open()){

cerr通常这意味着,当您运行程序时,当前目录不是您期望的目录。请尝试将文件放在可以提供完整路径的位置。应该放在哪里?我无法更改完整路径的路径…可能我需要更改xcode中的设置(我不知道如何在xcode 6中执行此操作)
int main() {

const int UC_SIZE = 10;
const int SMC_SIZE = 5;
const int SMC_UC_GRADS_SIZE = 2;
Student* uc = readStudentsFromFile("sample_uc_students.txt", UC_SIZE);
Student* smc = readStudentsFromFile("sample_smc_grads.txt", SMC_SIZE);
//const int UC_SIZE = 350000;
//const int SMC_SIZE = 75000;
//const int SMC_UC_GRADS_SIZE = 25000;
//Student* uc = readStudentsFromFile("uc_students.txt", UC_SIZE);
//Student* smc = readStudentsFromFile("smc_grads.txt", SMC_SIZE);

// Rough timing
time_t start, end;

time(&start);
Student* common1 = findCommonStudents1(uc, UC_SIZE, smc, SMC_SIZE,
                                       SMC_UC_GRADS_SIZE);
time(&end);
cout << "Using linear search it took " << difftime(end, start) << " seconds."
<< endl;


sort(common1, common1 + SMC_UC_GRADS_SIZE);
writeStudentsToFile(common1, SMC_UC_GRADS_SIZE, "smc_grads_at_uc_1.txt");

time(&start);
Student* common2 = findCommonStudents2(uc, UC_SIZE, smc, SMC_SIZE,
                                       SMC_UC_GRADS_SIZE);
time(&end);
cout << "Using binary search it took " << difftime(end, start)
<< " seconds." << endl;

sort(common2, common2 + SMC_UC_GRADS_SIZE);
writeStudentsToFile(common2, SMC_UC_GRADS_SIZE, "smc_grads_at_uc_2.txt");

delete[] smc;
delete[] uc;
delete[] common1;
delete[] common2;
return 0; }