Code bị lỗi không mở được file

Em muốn đọc thông tin nhiều sinh viên trong file notepad in thông tin sinh viên ra màn hình mà nó vẫn báo lỗi không mở được tập tin các anh giúp em với ạ

#include "stdafx.h"
#include <iostream>
#include <stdio.h>
using namespace std;
typedef struct MH {
	char mamh[15];
	char tenmh[50];
	int sotc;
	float diem;
};
typedef struct SV {

	char mssv[10];
	char hoten[50];
	int tuoi;
	int somon;
	MH kq[100];
	int tongtc, tongtctl;
	float dtbc, dtbtl;
};
typedef struct danhsach
{
	SV *arr;
	int n;

};

void docthongtinsv(char filename[], SV &s );
void docfile(char filename[], danhsach &ds);
void insv(SV s);
void xuatdanhsach( danhsach ds);


int main()
{
	danhsach ds;
	docfile("D:/TAPTIN", ds);
	xuatdanhsach(ds);

	return 0;
}
void docthongtinsv(char filename[], SV &s)
{
		char temp[100];
		FILE *fp;
		
		fopen_s(&fp,filename, "rt");

		if (!fp)
		{
			cout << "khong mo duoc tap tin!\n";
			return;
		}
		
		
		
		
		
			fgets(s.mssv, 10, fp);
			s.mssv[strlen(s.mssv) - 1] = '\0';
			fgets(s.hoten, 50, fp);
			s.mssv[strlen(s.mssv) - 1] = '\0';
			fscanf_s(fp, "%d", &s.tuoi);
			fscanf_s(fp, "%d", &s.somon);
			/*for (int i = 0;i < s.somon;i++)
			{

				fgets(s.kq[i].mamh, 15, fp);
				fgets(s.kq[i].tenmh, 50, fp);
				fscanf_s(fp, "%d", &s.kq[i].sotc);
				fscanf_s(fp, "%d", &s.kq[i].diem);

			}*/
			
		
			fclose(fp);
		
		/*	
			int tong = 0, tongtl = 0;
		float td = 0, tdtl = 0;
			for (int i = 0;i < s.somon;i++)
			{
				tong += s.kq[i].sotc;
				td += s.kq[i].sotc * s.kq[i].diem;
				if (s.kq[i].diem >= 5.0)
				{
					tongtl += s.kq[i].sotc;
					tdtl += s.kq[i].sotc*s.kq[i].diem;
				}
			}
			s.tongtc = tong;
			s.tongtctl = tongtl;
			s.dtbc = td / tong;
			s.dtbtl = tdtl / tongtl;*/
		
		
}


void insv(SV s) 
{

		printf("Ma so SV : %s\n", s.mssv);
		printf("Ho va ten: %s\n", s.hoten);
		printf("Tuoi     : %d\n", s.tuoi);
		printf("So mon   : %d\n", s.somon);
	
}
void xuatdanhsach( danhsach ds)
{
	for (int i = 0; i < ds.n; i++)
	{
		cout << "\n\n\t\t SINH VIEN THU " << i + 1;
		insv(ds.arr[i]);
	}
}
void docfile(char filename[], danhsach &ds)
{
	char temp[100];
	FILE *fp;

	fopen_s(&fp, filename, "rt");

	if (!fp)
	{
		cout << "khong mo duoc tap tin!\n";
		return;
	}


	fscanf_s(fp, "%d", &ds.n);
	fgets(temp, 100, fp);
	fgets(temp, 100, fp);
	for (int i = 0;i < ds.n;i++)
	{
		docthongtinsv(filename, ds.arr[i]);
	}
	fclose(fp);

}
"D:/TAPTIN"

Có đúng tên chưa, đường dẫn nhìn như tên thư mục.

Hay cách kiểm tra chưa đúng?
Tham khảo trên MSDN: https://msdn.microsoft.com/en-us/library/z5hh6ee9.aspx

2 Likes
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?