Getting program to open text file

The program is supposed read checker board moves from a text file and print them to the screen. Everything compiles correctly but it keeps saying ""Error opening file, the program will close" meaning the file is not being opened. What am I doing wrong?

Data File:
UL 2
DL 5
UR 6
DL 7
DR 2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <fstream>
#include <string>
#include <iostream>
#include<stdio.h>
#include<conio.h>
using namespace std;

int main()
{
	int numOfSpaces, counter = 0;
	string direction; 

	ifstream intData;
	intData.open("C:\\Users\T_Dub\Desktop\data.txt");

	if(!intData)
	{
		cout<<"Error opening file, the program will close.\n\n";
		getch();
		return 0;
	}
	
	while ( !( intData.eof() ) )
	{
		intData >> direction >> numOfSpaces;
		cout << direction << numOfSpaces <<endl;
	}

	getch();
	intData.close();
	return 0;
}
Last edited on
intData.open("C:\\Users\\T_Dub\\Desktop\\data.txt");

or, better:

intData.open("C:/Users/T_Dub/Desktop/data.txt");
Topic archived. No new replies allowed.