mitrmkar 1,056 Posting Virtuoso

Have you visited
http://www.neurotechnology.com/fingerprint-scanner-digitalpersona-u-are-u-4000.html

Looks like there are 3 available SDKs, perhaps with helpful sample applications. Moreover, they seem to have a dedicated forum there, so that might be a good place to post questions.

mitrmkar 1,056 Posting Virtuoso

>> My C++ is rather old but this should work.
Sorry but that will not work either. Consider compiling the code that you post. Even if you are posting minimal snippets/one-liners.

mitrmkar 1,056 Posting Virtuoso

Based on your reply, I take that you are seeing too much red at the moment. But anyhow, I'd suggest that you get over that, and instead go through the replies you received, improving your tutorial. After all, that's the purpose of these replies, don't you think so too?

PS. Also note that your post could have been completely ignored, but it wasn't.

Aia commented: Absolutely. +8
mitrmkar 1,056 Posting Virtuoso

It looks like you are doing assignments (=) instead of comparisons (==), so check your if-statements ..

// You want to have ..
if(board[x][y] == '.')
...

And please use code tags.

mitrmkar 1,056 Posting Virtuoso

About Malloc
Malloc() is ...

It is malloc (not Malloc).

References

No references guyz ... Only one my "brain" .. LOL..

You can find the current draft standard here ..
http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf

mitrmkar 1,056 Posting Virtuoso

Below is a safer version in terms of getting the input without std::string i.e it can easily be done with char arrays too.

Otherwise, the program is functionally practically the same i.e. the for-loop and the if-statement (that does not break the loop), are as in the original, however this version gets the count right ;)

Now empror9, can you figure out why does this happen?

#include <iostream>
#include <iomanip>  // <- because of setw()
using namespace std;

int main()
{
  // The size of the array, note: 'const'
  const int array_size = 30;

  int count = 0;

  // !! Attention !!
  // Initialize the whole array to '\0'
  char str[array_size] = "";

  cout << "enter a word: " << endl;

  // Safely get the input, no fear of buffer overflow
  cin >> setw(array_size) >> str;

  for (int x = 0; x < array_size; x++)
    if(str[x])
    {
      count++;
    }

  cout << count;

  return 0;
}
mitrmkar 1,056 Posting Virtuoso
#include <iostream>

int main ()
  {
    int count=0;
    char* str;

    std::cout << "Enter word: " << std::endl;
    std::cin >> str;

    for (;*str!='\0';count++,*str++) {}
    std::cout << count;
  }

Hmm, have you tested that? Does it work as expected?

mitrmkar 1,056 Posting Virtuoso

I must load it in the center of client area and after there moving using keys but it doesn't work

Just quickly commenting on this keyboard ineffectivity, what do the following lines do?

pt.x=new_rect.left;
pt.y=new_rect.top;
mitrmkar 1,056 Posting Virtuoso

Why the hell is there an i, does it means something, it's just an easy way to remember something or what?.

Relax and read some Wikipedia -> loop counter

FYI. If you don't like (too) short variable names, you are free to pick your poison. I think, C++ standard recommends that an identifier would be allowed to be 1024 characters long (the minimum).

mitrmkar 1,056 Posting Virtuoso

Just a suggestion, maybe you'd be better off without strtok()/atoi() altogether, using sscanf() instead. A minimum example to try out ..

#include <stdio.h>

int main()
{
  const char * str = "255.255.255.0";
  int arr[4];

  int res = sscanf(str, "%d.%d.%d.%d", &arr[0], &arr[1], &arr[2], &arr[3]);

  /* Did sscanf() convert 4 fields? */
  if(res == 4) {
    printf("OK: %d-%d-%d-%d\n", arr[0], arr[1], arr[2], arr[3]);
  }
  else {
    printf("Failed, res = %d\n", res);
  }

  return 0;
}
mitrmkar 1,056 Posting Virtuoso

Inside freqMake() you ignore its own return value twice. Then, lines 218 through 228 (the latest code) look like needing attention.

PS. void main() should be int main() .

mitrmkar 1,056 Posting Virtuoso

You might post the current code and point out the current problems.

mitrmkar 1,056 Posting Virtuoso

I think you are getting there.

mitrmkar 1,056 Posting Virtuoso

Besides, the variables mousex and mousey are not used in that version of the program, they are merely declared so I don't get why it's not working.

Again, what you are experiencing sounds like memory overrun(s) somewhere i.e. by introducing extra variables at 'proper places', problems magically disappear (and vice versa). Perhaps read Wikipedia Buffer overflow for some insight.

Use debugger and step through the code line by line. Observe how your variables/functions are behaving.

PS. You might also search/post in a SDL forum.

mitrmkar 1,056 Posting Virtuoso

I believe you are missing #include <windows.h> So make sure you have

#include <windows.h>  // <- first this
#include <sql.h>      // <- and then this
mitrmkar 1,056 Posting Virtuoso

In freqMake(...), you allocate a new Node but fail to initialize its pLeft and pRight pointers (when tree != 0 ). Later on you end up using these pointers, which gives you the error.

mitrmkar 1,056 Posting Virtuoso

To restate, since it took me a while to figure out exactly what you meant, take out the semi-colon at the end of your loop definition.

Note that there is also an unfortunate comma inside the original loop.

mitrmkar, please be a little more explicit next time. Noticing one minor character change can be difficult to spot without pointing out the change.

The OP is welcome to ask more questions, if needed (i.e. there was something left to be figured out). Though you may be right that in this case it might have been better to point things clearly out (only the OP knows).

mitrmkar 1,056 Posting Virtuoso

I see you quite quickly realized how to use code tags, that's nice.

Unfortunately, as it stands, the code is simply unreadable due to almost no formatting at all. So, try formatting the code properly and re-post it - otherwise, I doubt no one is going to take a look at it. And seriously, go the extra mile and come up with specific questions/details - I hope you get the point :)

mitrmkar 1,056 Posting Virtuoso

Please use code tags -> What are code tags?
You still have ~25 minutes to edit your post and fix the tags.

Then you might try to be more specific as for your problems.

mitrmkar 1,056 Posting Virtuoso

Your for-loop is wrong ..

void getRaise(double pay[], int size)
{
// should rather be ..
for(int x=0; x <size; ++x)
...
Salem commented: Nice catch +20
iamthwee commented: It was obvious to me! +11
mitrmkar 1,056 Posting Virtuoso

Perhaps have a look at priority_queue::priority_queue.

mitrmkar 1,056 Posting Virtuoso

It's essential that you get these format strings right from the very beginning. Since you mentioned Dev-C++, I take that your compiler is gcc or g++. If so, then pass the -Wall compiler flag to your compiler - that enables most of the warnings and should make it detect mismatching arguments to printf/scanf et al.

Some related documentation -> fscanf/scanf/sscanf

mitrmkar 1,056 Posting Virtuoso

All the time, at least in the C and C++ forums.

mitrmkar 1,056 Posting Virtuoso

main.cpp:48: warning: format '%s' expects type 'char*', but argument 2 has type 'int*'
main.cpp:153: warning: format '%s' expects type 'char*', but argument 2 has type 'int*'

You want to treat these warnings as actual errors and fix them.

PS. The line numbers of these two warnings match the line numbers in the code you've posted.

mitrmkar 1,056 Posting Virtuoso

What you are experiencing sounds like memory overrun(s) somewhere i.e. by introducing extra variables at 'proper places', problems magically disappear.
So, check e.g. that
- array/buffer indices are within the limits (remember, indices are zero-based).
- memory allocations are sufficiently large
- the SDL functions succeed (if they fail, use SDL_GetError() )

P.S. Since SDL_Event is a struct, you might want to pass it by reference i.e.

void boton::accion(SDL_Event & event,SDL_Surface **imgboton)
// or const reference, if it's not to be modified
void boton::accion(const SDL_Event & event,SDL_Surface **imgboton)
mitrmkar 1,056 Posting Virtuoso

but the final output comes out in the form of an infinite loop

Adding one thing...
you are writing to a file named "emp.dat" and then trying to open "emp.txt", which presumably does not exist (?). The bad usage of .eof() does not protect you from this. You can use .is_open() for checking whether a file was opened or not.
So, get rid of the .eof() there and read properly from the file the way Ancient Dragon showed. Naturally, pay attention to other suggestions too ;)

mitrmkar 1,056 Posting Virtuoso

What are the values of

MOUSEDOWN
MOUSEUP
MOUSEOUT
MOUSEOVER

They must be in the range 0..3, inclusive.

mitrmkar 1,056 Posting Virtuoso

The output does not really match with the code you've posted, too bad. But I suspect that something like following occurs ..

// You prompt for the dog's name ..
cout << "Enter dog1's name: ";
// Note: weight
cin >> dog1->weight;

// You actually typed in a string above
// and knocked out cin while doing that i.e. cin is 
// non-functional at this point and the following 
// attempt to read fails (weight retains its original value)
cin >> dog1->weight;

That kind of situation you can remedy using cin.clear() perhaps along with cin.ignore() .

mitrmkar 1,056 Posting Virtuoso

Your duplicate() methods are consistently wrong. Instead of passing an address of an object on stack like you do, allocate the object from the heap using new and return the pointer to it.

For example ..

shape *duplicate()
{
  return new square(length);
}

And once you've done with the duplicated objects, remember to delete them.

the main area of concern is line 152:

shapelib.push_back(new prism(d,*shapelib[n-1]));

Note that n - 1 must not result in a negative value.

mitrmkar 1,056 Posting Virtuoso

Please use code tags.

What does

cout << RegOpenKey(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Run\\microsoft security",&hKey) << endl;

say ?

mitrmkar 1,056 Posting Virtuoso

As for the camera problem, maybe focus on the parts of code that call Gun::shoot() and see if youl find anything suspicious/problem-related. Have you considered posting to a Dark GDK forum?

In the Gun::update() , the for-loop is not quite right. It only works correctly when no bullets end up being out-of-range after the call to move() .

PS. In the future, rather start new threads than continue the old ones.
This is to avoid the threads from turning into 'lengthy discussions' more or less unrelated to the initial problem.

mitrmkar 1,056 Posting Virtuoso

You don't want to have the vector ( mydouble ) declared inside the for-loop, because that gives you a fresh re-constructed vector on every iteration of the loop. So declare the vector in another scope, outside the loop.

mitrmkar 1,056 Posting Virtuoso

Are you aware of (all) the autorun.inf entries and what you can do with them. I'm not 100% sure, but I think you might very well do without any extra compiled executable on the CD.

If you still think you need this executable, what exactly would this executable do? Ancient Dragon already asked this, but you did not actually answer the question.

mitrmkar 1,056 Posting Virtuoso

You might also have a look at The #include Directive

mitrmkar 1,056 Posting Virtuoso

If you'd be allowed to do that, it would make const quite meaningless, since you'd get a non-const iterator, through which you could modify the (const) vector.

mitrmkar 1,056 Posting Virtuoso

Mm, maybe try Process Monitor and capture the build process. You'll get to see in detail pretty much everything that VS is trying to do.

mitrmkar 1,056 Posting Virtuoso

You cannot a pass an iterator to at(). Read up about its parameter.

mitrmkar 1,056 Posting Virtuoso

Your compiler may have a verbose option (i.e. some switch), which would enable you to see where it is actually looking for the include files.

mitrmkar 1,056 Posting Virtuoso

what the heck is going on?

cout << "Your score is: " + finalPoints_

You want to change the '+' there to something else.

Salem commented: Nice catch! +20
mitrmkar 1,056 Posting Virtuoso

the output program at the end is blank.

The input file is not opened? You might use .is_open() to check that.

mitrmkar 1,056 Posting Virtuoso

SOLVED IT!:

added fflush(stdin);

Oh no, perhaps reconsider and find another solution to the problem, read e.g. Things to Avoid in C/C++ -- fflush(stdin)

mitrmkar 1,056 Posting Virtuoso

One basic Windows tutorial is theForger's Win32 API Tutorial

mitrmkar 1,056 Posting Virtuoso

In the derived constructors, you want to to pass the pID to the base class.

mitrmkar 1,056 Posting Virtuoso

I think the trouble is due to const vector<double> &GetData() .

mitrmkar 1,056 Posting Virtuoso

i am new at c++ so plz help me to solve this home work i need marks plz

You should be paying more attention to the assignment. You are required to write C programs (not C++).

You might also read We only give homework help to those who show effort

mitrmkar 1,056 Posting Virtuoso

Introduce a new scope {} inside the case, like so ..

switch (service) {
case 'D' :
  { // new scope begins ..
   ... your code here as is ...
  } // .. and ends
case ...
mitrmkar 1,056 Posting Virtuoso

Hmm, you should have the following kind of construct ..

class Registry
{
  ...
  bool open_key_ex(HKEY hkey, const char * key, HKEY & hkey_out);
  ...
};

bool Registry::open_key_ex(HKEY hkey, const char * key, HKEY & hkey_out)
{
    return RegOpenKeyEx(hkey, key, 0, KEY_READ, &hkey_out)
    == ERROR_SUCCESS ;
}
mitrmkar 1,056 Posting Virtuoso

the switch statement doesn't even run.

Add a default case ..

switch (choice)
{
  case 'y':
    ...
  break;
    ...
  default:
  cout << "default case: " << choice << endl;
  break;
}

>> That can't be a problem with bounds, can it?
If you trash memory, anything can happen.

mitrmkar 1,056 Posting Virtuoso

Please use code tags.

HKEY subhkey;
// You are using the object's handle here,
// you should use the passed-in hKey instead
if(open_key(hkey , name))
{
  // subhkey is used uninitialized here
  enum_key(subhkey , level + 1);

open_key() is lacking wrt. returning a value as supposed - you must return a value in all cases.

You might add the following

bool open_key_ex(HKEY hkey, const char * key, HKEY & hkey_out)
{
    return RegOpenKeyEx(hkey, key, 0, KEY_READ, &hkey_out)
    == ERROR_SUCCESS ;
}

And then ..

void Registry::enum_key(HKEY Hkey , DWORD level)
{
  int i = 0;
  while(RegEnumKeyEx(Hkey , i , name , &size , 0 , 0 , 0 , &filetime) != ERROR_NO_MORE_ITEMS)
  {
    cout << i << ":" << name << endl;
    i++;
    size = sizeof(name);
    HKEY subhkey;

    // Use the Hkey as the parent key ..
    if(open_key_ex(Hkey , name, subhkey))
    //if(open_key(hkey , name))
    {
      enum_key(subhkey , level + 1);
      RegCloseKey(subhkey);
    }
  }
}

And be sure to initialize size = sizeof(name); .

mitrmkar 1,056 Posting Virtuoso

Line #12, subhkey would be used uninitialized at that point, even if your class declares a member: HKEY subhkey .

Then, are you sure you posted the actual code, I think, open_key(hkey should rather read open_key(hKey ?

>> but what he does is enumerate twice the subkeys of the HKEY_CURRENT_USER
Perhaps post more (actual) code, showing how enum_key() gets called.