Mình gặp một số vấn đề trong đoạn code này, các bạn xem qua rồi giải thích mình bị lỗi gì nhé, thật tình mình chẳng hiểu sai ở đâu cả,F5 thì nó báo "File has stopped working", chạy trên VS 2013.
Mã:
#include<stdio.h>
#include<conio.h>
#define LENGTH 128
long countWord(FILE* fin)
{
	long count = 0; char word[LENGTH];
	while (fscanf_s(fin, "%s", word) > 0)
		count++;
	return count;
}
void main()
{
	//char*fname = "E:\\Notepad.txt";
	FILE*f; fopen_s(&f, "E:\\Notepad.txt", "rt"); //f=fopen(fname,"rt") ;
	if (f != NULL)
	{
		long cnt = countWord(f);
		printf("%ld", cnt);
	}

	//fclose(f);
	_getch();
}