Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

After the while loop that starts on line 8 of the code you posted you need to add another while loop that searches for the next non-space character so that the function skips all spaces between words.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you don't. Use fgets() to read the data from the port until there is no more data to read -- fgets() returns NULL. Its very much like reading data from a file.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That is not c++ code.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Those are debug version of the libraries. Recompile your program for release version and it may work on other computers. computers.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what version of borland compiler do you have? I use Microsoft VC++ 2010 Express which is free.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

How to fix? Use a different compiler that supports BGI graphics. See this link

Or better yet, use win32 api graphics functions. It has a circle() function as well as several others which are similar to Borland's DOS BGI.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 27: The argument to strlen() is a char* or const char*, not FILE*. FILE is not a character array.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Although that compiles I don't think it will run. This should cause a coredump or crash because it uses an uninitialized pointer

int main()
{
    A *a;
    a->create();
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Not possible. The programmer can create it either on the stack or on the heap -- the choice is up to him/her. The object has no idea where it is in memory.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I have to include <sstream> header file. And you don't need atoi() because stringstream is a safer way to convert the string to an int.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

code 1 does not work because line 2 is assigning a value of 8 to some random memory location. p is a pointer that points to god only knows what.

code 2 is just initializing the pointer to address 0x00000008. Normally pointers should be initialized with 0 to indicate its a NULL pointer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

string literals such as in your second code can not be changed because the compiler probably puts string literals in read-only memory.

The first example is making a copy of the string literal which the compiler places in read/write memory, so there is no restriction on writing to that memory location. However ... the first program still will not work correctly because there was not enough roon allocated for the first string to hold the second string.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

depends on the operating system. MS-Windows you might want to use a game engine such as DirectX or OpenGL (both are free).

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Example:

#include <iostream>
#include <string>
#include <Windows.h>
using std::cout;



BOOL CALLBACK MyEnumProc(HWND hWnd, LPARAM lParam)
{
    char title[500] = {0};

    GetWindowText(hWnd, title, sizeof(title));
    if(strstr(title, "Notepad"))
    {
        HWND* windowHandle = (HWND*)lParam;
        *windowHandle = hWnd;
        cout << title << '\n';
        return FALSE;
    }
    return TRUE;
}

int main()
{
    HWND windowHandle = 0;
    EnumWindows(MyEnumProc, (LPARAM)&windowHandle);
}
Kesarion commented: Great example ! +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The memory is not really lost "forever" -- most operating systems reclaim the memory when the program itself exits either normally or abnormally (crashes). When using current versions of MS-Windows or *nix it is not necessary to reboot the computer.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>do there profane programming

Its their not there. :) And yes, we were all beginners at one time or another.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Is it because I'm sending these to "Edit" ?
Probably not. You are wasting a huge amount of time calling FindWindow() so often. Call it only once and store the result in a variable.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

SendMessage() only sends events to the current thread, so it won't work with other threads/procsses. PostThreadMessage() may or may not work, depending on what the thread is doing at the time (see this link for more info about that).

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Well, in that case just do it the hard way -- put this in a loop if( string[i] >= '0' || string[i] <= '9' )

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Now what you are wanting to do is a little different than your original question. I think what you want is to use virtual methods

class Animal
{
public:
   virtual void Speak() = 0;
};

class Cat : public Animal
{
public:
   virtual void Speak() { cout << "Meow\n"; }
};

class Dog : public Animal
{
public:
   virtual void Speak() { cout << "Wolf\n"; }
};

void foo(Animal& a)
{
   a.Speak();
}


int main()
{

   Cat c;
   Dog d;
   foo(c);
   foo(d);
}

>>can this be acheived via the command line argument?

This is just one of several possibilities

int main(int argc, char*argv[])
{
   Cat c;
   Dog d;
   if( argc == 2)
   {
      if( strcmp(argv[1],"Cat") == 0)
          foo(c);
      else if( strcmp(argv[1],"Dog") == 0)
          foo(d);
   }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Look for books on Windows Programming at amazon.com or your local Barns & Noble. Its unlikely you will find anything that describes everything that windows.h has to offer. But you will find quite a few books about how to write windows gui programs using pure win32 api, MFC, Forms, C#, etc.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is an article that explains how to do it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It would be helpful if you posted the code you wrote.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

One way is to use threads. Another way is to use non-standard functions contained in conio.h -- but your compiler may or may not suppport them.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If DaniWeb is unavailable then how would it generate an email??? The admins probably already know about the problem so generating hundreds of emails to them would do nothing more than fill up their email box.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

use a font editor to edit an existing font

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Is there a question somewhere in all that code?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The reason the two expressions are different is because in the first one the value of num can be anything other than 64 in order to satisfy the expression. But in the second expression the only value of num that satisfies the expression is 65 because 65-65 is the only thing that make it 0.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

#2 depends on the compiler and operating system. The size of an int in a 32-it program may not be the same as in a 16 or 64-bit program.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I think you need to clarify what you mean because I certainly don't know what you are talking about.

// function prototypes which may or may not be in the same *.cpp file as main()
int foo1(int), foo2(int), foo3(int), foo4(int) // etc. etc for each of the functions.  


int main()
{
    int data = 123;
    foo1(data);
    foo2(data);
    foo3(data);
    foo4(data);
    foo5(data);

    // now repeat the above line for as many times as you want to
}

>>I have seen command line argumants but they do not seem to call those millions of funtions through objects.

command-line parameters are only strings, not functions, so that do not call anything.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>"mark forum as solved" link.

Must be a new button, I only knew we could marks threads solved, not entire forums :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you are running MS-Windows I suppose you could call GetSystemTime() and use milliseconds as the seed value.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

CS is just a general category, very similar to the term "Business Administration". The books you will want to read will depend on your interests. Go to a local book store such as Bsrns & Noble and you will find hundreds of books in the CS field.

>>I am too late into my college career to take any more classes
Why? What's stopping you from getting a second degree? Many students have duel majors, you should discuss that with your college counselor.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Post your code here instead of posting a link on some other computer -- which would not respond when I tried to read it. Just simply copy and paste the code in your post and surround it with [code] ... [/code] code tags.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> if(search[ctr] == array[8][ctr])

lines 14 and 23: you are using the wrong index (8) into array. Valid index numbers are 0, 1. 2, ... 7. The number 8 is beyond the bounds of the array.

line 16: add break to stop the loop

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You are using time() as the seed to srand(). Call srand() only once during the lifetime of the program, not every time you call rand(). Put the call to srand() near the beginning of main() and you will see different results every time rand() is called.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What makes you believe that rand() only produces one random value per second? Have you profiled it? What is the speed of your computer? A computer with a faster CPU will process code faster. I wrote a little program that generated 1,000,000 randm numbers on 43 millisonds and if I add the mod operator like you posted it generates them in 62 milliseconds.

If you are looking to speed up a program then look elsewhere.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>


int main()
{
    time_t t1, t2;
    srand((unsigned int)time(0));
    t1 = clock();
    for(size_t i = 0; i < 1000000; i++)
        rand();
    t2 = clock();
    printf("time %u\n", t2 - t1 );

}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you know how to pass the data to one function then there should not be a problem passing it to a million or more functions. The number of files (*.c or *.cpp) has nothing to do with it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Several similar errors. Since you are not using using namespace std; then you need to specify std:: namespace wherever STL objects are declared, such as in the hashItem class hashItem(const std::string &k, void *pt = NULL); >>static unsigned int hashTable::getPrime(int size
Remove the static keyword in the implementation file. Its only used in the header file.

>>int primes [21] = {3, 11, 17, 37, 67, 131, 257, 521, 1031, 2053, 4099, 8209, 16411, 32771, 65537, 131101, 262147, 524309, 1048583, 2097169};

Move that line from the header file to the *.cpp implementation file. In the header file just put this: extern int primes[];

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Maybe because there is no such standard C or C++ function.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Now that you posted the code that works, post the code that doesn't work and also a few of the compiler errors.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

EN_UPDATE is posted when the control is in the process of repainting itself so that you can resize the control or take some other actions. This means EN_UPDATE may be posted for for events other than keyboard, such as when the window becomes in focus.

EN_CHANGE is sent when the user has taken an action that may have altered text in an edit control.

EN_KEYUP and EN_KEYPRESS events are not captured by the edit control unless you subclass it. Otherwise they are eaten up by MFC.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Depends on the file and its contents. CFile is not a good choice for reading strings (standard text files) unless you also want to use CArchive and CString. If you don't have to serialize MFC classes then I would use standard c++ fstream

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't like it at the bottom either -- just makes it more difficult for new people to learn how to use DaniWeb.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can freely advertise at one of these DaniWeb links

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Congratulations -- you just answered a four-year-old long dead thread.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It doesn't matter -- use any SQL compliant database you want.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

As we said before you could use any of the STL containers.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>i know for a fact that cmd.argv(1) at that point is "vars.rc"

But is that file in the program's current working directory? Try running your program with the full path to the file and see if that works, or move the file into the program's current working directory.

>>if(cmd.argc() != 2)
I may be wrong but that looks more like c++ than C.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

There are lots of ways to do it -- which one you use will depend on the data you want. std::string is a c++ class that manages chracter arrays and expands/contracts it on demand. vector, list, set, and map manage arrays or lists of objects, and also expand/contract on demand. Fially you could roll your own for any of the previously mentioned, but that involves a lot of work on your part and is very error-bug prone, which is the reason they are in the c++ language.

[edit]^^ Sorry Edward I didn't see your post.[/edit]