William Hemsworth 1,339 Posting Virtuoso

>I'll list them in order worst to best
I wouldn't say that's the best order, why create your own malicious keyboard driver when you can just use a windows hook? But transferring the information that's been logged is out of the question, as long as you get the key strokes, what happens with the data is up to s_sridhar, and doesn't really fit in any of those three points.

William Hemsworth 1,339 Posting Virtuoso

I noticed this too, thanks for the links :icon_lol:

William Hemsworth 1,339 Posting Virtuoso

Waoh? I like that :icon_cheesygrin:

Your Brain Usage Profile:

Auditory : 50%
Visual : 50%
Left : 50%
Right : 50%

William, you are one of those rare individuals who are perfectly "balanced" in both your hemispheric tendencies and your sensory learning preferences. However, there is both good news and bad news.

A problem with hemispheric balance is that you will tend to feel more conflict than someone who has a clearly established dominance. At times the conflict will be between what you feel and what you think but will also involve how you attack problems and how you perceive information. Details which will seem important to the right hemis- phere will be discounted by the left and vice versa, which can present a hindrance to learning efficiently.

In the same vein, you may have a problem with organization. You might organize your time and/or space only to feel the need to reorganize five to ten weeks later.

On the positive side, you bring resources to problem-solving that others may not have. You can perceive the "big picture" and the essential details simultaneously and maintain the cognitive perspective required. You possess sufficient verbal skills to translate your intuition into a form which can be understood by others while still being able to access ideas and concepts which do not lend themselves to language.

Your balanced nature might lead you to second-guess yourself in artistic endeavors, losing some of the fluidity, spontaneity and creativity that otherwise would …

Ancient Dragon commented: you cheated :) +36
William Hemsworth 1,339 Posting Virtuoso

If you're using windows, it's best to start with a Win32 API tutorial.
It eventually covers the topic of bitmaps, but considering you are new to the language, you may want to learns some of the basics before trying that tutorial.

William Hemsworth 1,339 Posting Virtuoso

What a horror !!!
It is not a keylogger at all !
Ask on Professional Win32 api Group
to learn how to make real keyloggers..

I'll agree that it's not the best keylogger, but it works. The best way is to use a windows hook, which has already been suggested.

William Hemsworth 1,339 Posting Virtuoso

Franz Ferdinand :icon_cheesygrin:

William Hemsworth 1,339 Posting Virtuoso

With some tweaking, this snippet should help.

William Hemsworth 1,339 Posting Virtuoso

Your personal information is at LOW RISK

That's a relief ; )

William Hemsworth 1,339 Posting Virtuoso

Thanks for your reply :]

But I didn't find those links too useful. I've already managed to make a function to solve the sudoku's, but I need to figure out how to generate them with different difficulties. I've already looked around on the net for quite a while, but couldn't find too much information on how to generate sudoku's. And the first link was in C#, and was hard to understand for me :icon_eek:

William Hemsworth 1,339 Posting Virtuoso

Hi,

I've been working on a sudoku game, which seems to be working pretty well so far. I've managed to make a basic solver, and the interface is pretty nice :icon_cheesygrin: But i'm having problems trying generate a random unique sudoku. I need to be able to create 3 different difficulty level sudoku's, and I don't want them to take long to generate.

For example, say I have these functions.

struct cell {
  int value;
};

struct sudoku {
  cell grid[9][9];
};

void solve_easy(sudoku &sud) {
  // Working
}

void generate_easy(sudoku &sud) {

  // Reset sudoku
  for (uint x = 0; x < 9; ++x) {
    for (uint y = 0; y < 9; ++y) {
      sud.grid[x][y] = 0;
    }
  }

  // How do I generate an easy sudoku here?
}

I was thinking to first totally fill up the grid with valid integers (which is the first problem), and then keep removing one random number from the grid until it is no longer solvable using my basic solver. At that point, I put back the last number I removed from the grid. Would that give me a unique sudoku?

If not, what other ways could I manage this? any help would be appreciated :icon_lol:

The project is over a 1000 lines and wouldn't help much anyway, but I will attach the executable (along with one previously saved sudoku to show the solver works) to show you what I mean a little better.

Thanks.

William Hemsworth 1,339 Posting Virtuoso

>and that guy who says they're 15: shut up and get lost kid
No, I was here first.

Nick Evan commented: haha :) +14
verruckt24 commented: not that easily ;) +3
William Hemsworth 1,339 Posting Virtuoso

Seems pretty simple to me, add this to the dialog message procedure, and windows shouldn't handle the ALT-F4.

case WM_SYSKEYDOWN: break;
William Hemsworth 1,339 Posting Virtuoso

Purely because serkan sendur revived the thread, so I viewed it thinking it was fairly recent news.

William Hemsworth 1,339 Posting Virtuoso

Don't go! :<

Wait... how old is this thread?

William Hemsworth 1,339 Posting Virtuoso

Creating your own strcat is nothing, it takes literally a couple of lines.

void my_strcat(char *dest, char *source) {
  // Find null-terminator
  while ( *++dest );

  // Add new string
  while ( *dest++ = *source++ );
}

Making it safe would be the next problem. But think about what Lerner is telling you, you're assuming what the user inputs will be shorter than 128 characters, if you can't use std::strings, try learning how to use dynamic memory, or validating your input.

William Hemsworth 1,339 Posting Virtuoso

If you have to implement your own algorithm to do this, try taking a look at a snippet I made some time ago. Link

But otherwise, this is an easy problem, you could even try std::stringstream . You practically don't have to do anything :icon_lol:

#include <iostream>
#include <sstream>
#include <string>
using namespace std;

int main() {
  string sentence_s;
  stringstream sentence_ss;

  cout << "Enter a sentence: ";
  getline(cin, sentence_s);
  sentence_ss << sentence_s;

  string word;

  while ( sentence_ss >> word )
    cout << '\n' << word;

  cin.ignore();
}

If you can't do something like this, try using strtok , it will help you split up the word using a delimiter.

Hope this helps.

William Hemsworth 1,339 Posting Virtuoso

In case anybody else tries it.

for (size_t i = oldLength, j = 0; i < m_length; ++i, ++j)
  new_str[i] = other[[B]j[/B]];

I don't know what's wrong with me today, two mistakes in one thread :icon_redface:

William Hemsworth 1,339 Posting Virtuoso

Sorry, my mistake :P

String& String::operator +=(char* other)   {
  // Temporarily store the old length (for copying chars)
  size_t oldLength = m_length;

  // New size of string
  m_length += strlen(other);

  // Allocate enough space for the new string
  char *new_str = new char[m_length];

  // Copy string without null-terminator
  for (size_t i = 0; i < oldLength; ++i)
    new_str[i] = m_buffer[i];

  for (size_t i = oldLength, j = 0; i < m_length; ++i, ++j)
    new_str[i] = other[i];

  // Delete old chars
  delete[] m_buffer;

  // Assign new string
  m_buffer = new_str;

  return *this;
}

Haven't really tried compiling this, but I think it's right this time.

shasha821110 commented: good, expert, kind +1
William Hemsworth 1,339 Posting Virtuoso

Just write your own loop to copy chars without the null-terminator?
However, on this line:

m_length = [B]strlen[/B](m_buffer) + [B]strlen[/B](other) + 1;

You are using a function which relies on the null-terminator at the end of the string, so you will have to keep track of the string length yourself while adding characters to it. Something like this perhaps?

String& String::operator +=(char* other)   {
  // Temporarily store the old length (for copying chars)
  size_t oldLength = m_length;

  // New size of string
  m_length += strlen(other);

  // Allocate enough space for the new string
  char *new_str = new char[m_length];

  // Copy string without null-terminator
  for (size_t i = 0; i < oldLength; ++i)
    new_str[i] = m_buffer[i];

  // Delete old chars
  delete[] m_buffer;

  // Assign new string
  m_buffer = new_str;

  return *this;
}

Hope this helps.

William Hemsworth 1,339 Posting Virtuoso

My favourites have to be:
- Chrno Crusade
- Vampire Knight
- Hantsuki
- Kanokon (friend showed me it, found it funny)
- Basilisk
- Dragon Ball Z ;D (used to watch it when I was a kid)
- Vampire Princess Miyu

All I can think of at the moment.

William Hemsworth 1,339 Posting Virtuoso

Very nice links, thanks :icon_cheesygrin:

William Hemsworth 1,339 Posting Virtuoso

>I'm only 16
Grow up already, I'm 15 :icon_rolleyes:

Norbert X commented: stupid post +0
lllllIllIlllI commented: Stupid Norbert +1
William Hemsworth 1,339 Posting Virtuoso

>Learn to read please, there are at least 4 veggies here
My mistake, there's actually two. Name the other two for me.

>Meat makes you a man. If you don't have meat, you'r not a man
You talk absolute nonsense. I'm not even going to give a proper reply to that dumb statement.

>Greenies are n00bs or Newbies so that's why eating greens makes you a n00b(generic internet insult)
You're right, I cant comprehend that jibberish.

>in case your puny brain can't comprehend that much, Willy.
I think the way you finished that sentence, just showed how mature you really are... :icon_rolleyes:

William Hemsworth 1,339 Posting Virtuoso

Ugh what's with all the vegeterians on this site? Here's some trivia: If you are what you eat then if you ate pork, you'd be a pig. If you eat hamburgers, then your a cow. If you eat chicken, well you're a chicken. What would you be if you ate Vegetables? "Greenies" (Which means n00bs or newbies)

I'm not seeing your point. I'm not a vegeterian but I still don't like bacon.
If someone doesn't want to eat meat, why do you care?

> all the vegeterians on this site
What are you talking about? so far, i've seen only one vegeterian on this thread.

William Hemsworth 1,339 Posting Virtuoso

I like this song..
enjoy!

I guess you have an awful taste for music then :icon_wink:

William Hemsworth 1,339 Posting Virtuoso

Only problem I found, salt doesn't dissolve in water :icon_neutral:

William Hemsworth 1,339 Posting Virtuoso

In future, post using code-tags, show what errors you're having, and give more detail to your problem.

Just to get some sort of idea on indentation, I've formatted the code for you.

#include <iostream>
#include <fstream>
using namespace std;

void namefile(ifstream & infile);
void openfile(ifstream & infile);
void displayScores(int scores);
void getData(ifstream & infile, int scores[], int & size);

int main()
{
}

void nameFile(ifstream & infile)
{
  cout << "enter the file name";
  cin >> infile;
}

void openfile(ifstream & infile)
{
  ifstream infile;
  infile.open (std::ifstream & infile);
}

void getData(ifstream & infile, int scores[], int & size)
{
  int i = 0;
  while (infile)
  {
    infile >> scores[i];
    i++;
  }
}

void displayScores(int scores)
{
  cout << scores[i];
}

Now, what are you trying to do here?

void nameFile(ifstream & infile)
{
  cout << "enter the file name";
  cin >> infile;
}

You're asking the user to enter a file name, and then... :icon_rolleyes:

I'm not going to put much effort into figuring out what each function and line does / is supposed to do. So if you want more help, post some detail on what each function is supposed to do, and what the program itself is ment to do.

William Hemsworth 1,339 Posting Virtuoso

Perhaps be more specific... what exactly is it that you want to know?

William Hemsworth 1,339 Posting Virtuoso

Within Temptation, can't stop listening to them lately :icon_cheesygrin: Such an amazing voice she has.
http://www.youtube.com/watch?v=KrwDHVNdgdw

William Hemsworth 1,339 Posting Virtuoso

If its' on Windows, just use win32 api
(1 line of code..)

Go ahead then, tell us how to do it in one line.

mitrmkar commented: marco93 seems to be such a "one-liner", If I recall right. Let's see whether he will answer ... +6
William Hemsworth 1,339 Posting Virtuoso

Wow, very cool :)

William Hemsworth 1,339 Posting Virtuoso

Would you mind posting some more code? It can only make it easier to understand what's causing the problem.

William Hemsworth 1,339 Posting Virtuoso

Incredible... whatever it is :icon_cheesygrin:

William Hemsworth 1,339 Posting Virtuoso

Steven Curtis Chapman, his songs are just amazing - with some sad stories behind them too, especially after his 5 year old daughter died in a car accident. Cinderella, Remembering you - kinda wish they hadn't played this on Narnia, so instead I found a Chrno Crusade video with it instead :)

William Hemsworth 1,339 Posting Virtuoso

Ahh, chillin' to some Jack Johnson :)

http://www.youtube.com/watch?v=pNlmn7vbXBQ

Will Gresham commented: Good choice +1
William Hemsworth 1,339 Posting Virtuoso

... Forget this post :)

William Hemsworth 1,339 Posting Virtuoso

Why are you using the preprocessor for this?
This compiles and works for me:

#include <iostream>
using namespace std;

struct A1 {
  static const int _AINT = 0;
};

struct A2 {
  static const int _AINT = 1;
};

template< class T >
struct B{
  void Fun(){
    if ( T::_AINT == 1 ) {
      cout << "TADA!";
    }
  };
};

int main(void){
  B< A1 > b1;
  B< A2 > b2;
  b1.Fun();
  b2.Fun();
  return 0;
};
William Hemsworth 1,339 Posting Virtuoso

I've had it before, but ever since I formatted my pc, the problem seems to have gone.
I've always used firefox.

William Hemsworth 1,339 Posting Virtuoso

Since we are splitting hair, let's declare those int variables outside those for loops. Portability to the lowest common denominator should be a concern.

Switching between the C and C++ forum can be so confusing sometimes :)

William Hemsworth 1,339 Posting Virtuoso

True, what about if you're making a graph... and need to plot some x & y coordinates, what would be more readable?

for (int i = 0; i < 10; ++i) {
  for (int j = 0; j < 10; ++j) {
    graph.plot(i, j);
  }
}

or...

for (int x = 0; x < 10; ++x) {
  for (int y = 0; y < 10; ++y) {
    graph.plot(x, y);
  }
}

Just use what seems appropriate, and don't stick with i, j, k just because they are more commonly used.

William Hemsworth 1,339 Posting Virtuoso

I realized that comatose :icon_rolleyes: The fact is, if you click on someones username, it sometimes links you to somebody elses profile regardless of whether you refreshed the page or not. If I click on a link saying vmanes, it should link me to his profile, don't you think? Not a very big problem, I just thought i'd mention it.

William Hemsworth 1,339 Posting Virtuoso

In future, remember to use code tags.

Here is the code how I would have formatted it, after cleaning it up a little for you.

#include <stdio.h>

int main() {
  int x;

  printf("Enter an integer:\n");
  scanf("%d", &x);

  if ( !((x <= 20) && (x > 0)) ) {
    printf("\nYou have entered an invalid integer.\nPlease enter a number smaller or equal to 20:\n");
  }

  while ( (x > 20) || (x <= 0) ){
    printf("\nEnter a valid integer:\n");
    scanf("%d",&x);
  }

  printf("\nvalid");

  return 0;
}

prints sequence of asterisks in a single line based on the input gained using :
1.while
2.do-while
3.for

First, all three of these will do a very similar thing (loop until a condition is met), so the code for each will look quite similar.

So, if I understood correctly, you want to make a loop which will print as many asterisks' as the user inputs.

  • while:
    while ( x-- != 0 ) {
      printf("*");
    }

    This will keep decrementing x and displaying one asterisks at a time, until x == 0.

  • do-while:
    do {
      printf("*");
    } while ( --x != 0 );

    Same applies for this one, but as the order in which the code executes has been changed, you have to decrement x before comparing it with 0 (by changing it to --x instead of x--).

  • for:
    for (; x != 0; --x) {
      printf("*");
    }

    Once again, the same thing is happening, except the code looks a little different...

Nick Evan commented: Good explanation for this newbie +14
William Hemsworth 1,339 Posting Virtuoso

I came across a small bug recently when clicking on a link to a user profile. It seems that no matter what name you click on, it will only ever link you to the member who last posted in that thread. In my screenshots, I clicked on the link to view vmanes profile, yet it linked me to ArkM's profile page (the last poster).

William Hemsworth 1,339 Posting Virtuoso

I remember having that problem, I accidently set the snippet programming language to CPP instead of CPLUSPLUS which showed up in its own catagory. Seems to have been fixed now, but it would have been nice to be able to edit that at the time :-/

William Hemsworth 1,339 Posting Virtuoso

Hmm, an example of a memory leak.

int main() {
  int **a = new int*[10];

  for (int i = 0; i < 10; ++i)
    a[i] = new int[5];

  /* Do stuff with a */

  for (int i = 0; i < 10; ++i)
    delete[] a[i];
}

In this example, you freed the data each pointer was pointing at, but you fergot to free the space which was allocated for the pointers themselves. To fix this leak, you need to remember to free a.

delete[] a;
William Hemsworth 1,339 Posting Virtuoso

>i try this program, but something wrong with the loop function.
How unfortunate... you may get more help if you post what you've done up to this point.

William Hemsworth 1,339 Posting Virtuoso

>plz help its urgent...
Not for us.

>i actually want to read the raw file(CR2 file) of jpeg image using turbo C...
You shouldn't be using Turbo C in the first place, you should get yourself a decent compiler. You may be able to read the jpeg file using windows functions, but it would probably be a better idea to try googling for some of the JPEG librarys out there.

Hope this helps.

Salem commented: Helps me :) +29
William Hemsworth 1,339 Posting Virtuoso

Isn't there a checkbox on that dialog somewhere that says "Do not show this warning again", or something along those lines? If it's there, try pressing it :icon_confused:

William Hemsworth 1,339 Posting Virtuoso

I don't use MFC, so i'm not sure. Either way, as far as I know, there's no function in the windows api that allows you to add text to a window. If it were me, i'd just stick with the way I just showed you :icon_cheesygrin: It works.

William Hemsworth 1,339 Posting Virtuoso

The problem is easy to solve, instead of adding a new line to the text box, simply add the line to a global string, then assign the string to the textbox.

#include <windows.h>
#include <iostream>

HWND hEdit; // Text Box
std::string log;

void AddLogLine(char *line) {
  log += line;
  log += "\n";
  SetWindowText( hEdit, log.c_str() );
}

/* Rest of the Code *

You could also consider using a Listbox instead.

Hope this helps.