c file i/o vs c++ file i/o

In my program I want to record some keystrokes and send them to a file. When I use the "c" conventions for file I/O I am able to read keystrokes, however, using the "c++" conventions I am not able to get any output in my file.

Would anyone be able to explain why this is/where I went wrong? Also any good link/videos on how to get a good start on developing windows applications would be appreciated as well!!

Thanks so much!
-H

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lparam)
{
	ofstream myfile;
	FILE * f = fopen("a.log", "a");
	myfile.open("example.txt");

	
	
	
	switch(uMsg)
	{
		case WM_DESTROY:
		{
			PostQuitMessage(0);
			return 0;
		}
		case WM_CHAR:
		{
			
			
			
			switch (wParam)
			{
				/*
				case 0x08:
					cout << "h";
				case 0x0a:
					cout << "h";
				case 0x1b:
					cout << "h";
				case 0x09:
					cout << "h";
				case 0x0d:
					cout << "h";*/
				default:
					myfile << "hellosirrrr";
					fprintf(f, "%c", wParam);
					
					
					
			}
		}
		
		default:
			return DefWindowProc(hwnd, uMsg, wParam, lparam);


	}

	myfile.close();
	fclose(f);
}
>
Last edited on
Topic archived. No new replies allowed.