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

Mr ancient I have a question for you. You stated that you are using vista premium and running VB 6.0 in it.

I didn't say that at all. I have VC++ 6.0, not VB 6.0. But I don't use it very often anymore because the Visual Studio 2008 is a much better set of compilers. You would do well to get them too and stop using 6.0.

I fired up VB 6.0 and put a few controls on the form -- the initial display on the form was a little odd, but when I unclicked it the control appeared normally. Then I fired up VB 2008 Express and it worked a great deal better.

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

so if i want to do three boxes to i change the thread id to 1..???

No. You call CreateThread() for as many message boxes as you want to appear at the same time. The CreateThread() function will populate the dwThreadID integer with the appropriate number -- note the last parameter is a pointer.

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

Step 1: create a DLL project, copy and paste the code you posted here into the project, then hit the Execute-->compile.

Step 2: Correct all warnings and errors -- there are lots of them. Your "friend" used NULL when 0 should be used in many places. NULL is for pointers, 0 is for integers, although in c++ you can uses 0 for pointers too.

Otherwise I got it to compile without any other problems.

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

why don't you ask your "friend" how to compile it, afterall he wrote it.

Alex Edwards commented: My thoughts exactly XD +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I actually liked Narue's original avatar the best -- the one where she was yielding a chainsaw and wore a Jason-style mask :) :) :) :)

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

Unless you use modeless dialog boxes, as suggested by Ancient Dragon, you need to have multiple threads in order to display multiple message boxes simultaneously by means of the MessageBox() function.

Good sugestion

#include <windows.h>


DWORD WINAPI ThreadProc(LPVOID lpParameter)
{
    MessageBox(0,"Hello World From Thread", "HelloWorld",MB_OK);
    return 0;
}

int main()
{
    DWORD dwThreadID = 0;
    CreateThread(0,0, ThreadProc, 0,0,&dwThreadID);   
    MessageBox(0,"Hello World From Main Program", "HelloWorld",MB_OK);

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

Silly -- that isn't C, its win32 api, where you are at the mercy of Microsoft programming staff. There is a way to do it, but not by using MessageBox(). You have to create your own modeless dialog boxes. The only way I have done that is with MFC (Microsoft Foundation Class), but I'm certain it can be done with just win32 api functions as well. google for it and you might find example code.

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

put the strings in read-write memory like this: char suit[4][15] = {"Hearts", "Diamonds", "Clubs", "Spades"};

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

>>i get the same box repeating itself twice
It only appears to be the same box because you have the same identical text in each one. Change the text in one of the boxes and you should see the difference.

You can't show them both at the same time. Message Boxes blocks your program from running until one of its buttons is pressed.

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

doesn't matter -- you still can't change them because they are string literals.

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

You have a couple options
1) store it in the registry. This isn't very difficult to do and you should be abot to find pleanty of examples on the net via google.

2) store it in a normal data file

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

Aia -- I like your new avatar -- its sinister and mysterious.

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

Congratulations! Have a beer for me too :)

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

>>I can change the result of the memory location that the pointer points to, but not the string that begins at that address.
Those strings can not be changed because they string literals which reside in read-only memory.

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

You apparently didn't get a clean compile with the code you posed because it contains several errors. One error is function outputLine() -- One place passes fstream object as the first parameter while another passes ofstream. If I leave it as ostream like you have it then the function has millions of errors. My suggestion is to NOT use ofstream, but use fstream everywhere so that your program is consistent.

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

>>I can't find my hardware.dat file on the compute
It will be in the same directory that contains the program *.exe file.


>>the write in the updateRecord() function does not work.
what makes you think it doesn't work? What does it do that it's not supposed to do, or what doesn't it do that its supposed to do ? Just by looking at the function it appears to be working right, but since we don't have all the code for the entire program its not possible for us to test it.

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

>>It jumps from requesting a tool name to requesting the number in stock
That is the typical behavior of some previous cin for entering a number because when you enter a number the program leaves the '\n' (Enter key) in the keyboard buffer, then when entering a string cin thinks the Enter key is pressed. To solve that problem you need to clear the keyboard buffer of all its contents -- please read this thread about how to do that. You should put that code snipped after numeric data input.

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

Agree with what others have said. It might be easier to learn C before tackling c++. If you know fundamentals of C then C++ will be a snap. And if you know C++ C# and Java will also seem quite easy to learn.

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

Sounds almost like SQL O_O

Its not nearly as complex as SQL or relational databases.

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

SQL is a language, MYSQL is an implementation of that language. There are many different database engines that support the SQL language -- MySQL is only one of them. Others are Oracle, Sybase, and Microsoft SQL Server.

Shanti C commented: exaclty... +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If thats all your forum has for me then I'll leave, disappointed.

Bye. We aren't here to write your programs for you. Only you can do that.

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

So - where do I start? Please help me to do this.

We have already done that too, and I'm not going to repeat what everyone has told you. Go back and read those posts yourself, then take what they said and run with it.

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

I'm running Vista Home Premium for about a year and have some mixed feelings. I hated it before disabling some of the new security features because it asked too many questions. Now I have only two problems:
1) won't run a couple of the programs I had on XP, so I duel boot to XP and run them.

2) The screen saver frequently locks up when I move the mouse and takes a minute or so to disappear so that I can use the computer again.

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

>>And if any of you think I'm completely crazy
Yup. Remember, I didn't say that, you did :)

>> Please let me know that your thoughts are
I think we already have done. that.

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

>>Hacking = Writing?
Only in VB. In C and C++ its Hacking == Writing?

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

fread() should only be used when opening the file in binary mode. Doesn't matter if the file was originally written in text mode and contains CRLFs. When opened in binary mode there is no translation to '\n' because they are treated just like any other binary data.

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

does the file contain those dashes you posted ? If not, then just do something like this:

while( inFile >> temp[i][0] >> temp[i][1])
{
    ++i;
}

you have the rows and columns of that temp array backwards. row should be 12 and columns should be 2. You want the array to look something like this:

Col1  Col2
|------|-------|
|------|-------|
|------|-------|
|------|-------|
|------|-------|
|------|-------|
|------|-------|
|------|-------|
|------|-------|
|------|-------|
|------|-------|
|------|-------|
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I take offense to this.
You are supposed to :) Would you start building a house if you don't know the difference between a hammer and a screwdriver ?

Start at the beginning, learn to crawl before you walk. Buy an introduction to c or c++ book and start reading from page 1. There are many suggestions for good books in one of the Read Me threads at beginning of this c++ board. Read those threads, buy the book, then begin studying. After a couple years of studying you will probably be ready to tackle that project of yours.

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

The simplest, but slowest, way is to do a linear search -- start from the beginning of the file, read each record until you get the one you want. For files written in text mode there isn't much more that can be done to speed up the searches.

A more complicated method is to create an index file that contains key field values and the index value into the data file.

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

A couple possibilities:
1) copy the string in vScript into a character buffer then use that buffer for lpFile pointer.

2) explicitly specify the verb to be used. According to MSCN the default verb may, or may not, be "open", but is that what you want?

  • For systems prior to Windows 2000, the default verb is used if it is valid and available in the registry. If not, the "open" verb is used.
  • For Windows 2000 and later systems, the default verb is used if available. If not, the "open" verb is used. If neither verb is available, the system uses the first verb listed in the registry.
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Ok - there's nothing like a BIG challenge to start off my exploration into programming
HaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHa HaHaHaHaHaHaHaHaHaHaHaHa HaHaHaHaHaHaHaHaHaHaHaHa

Sorry, but I can't stop laughing! You don't know a thing about programming, yet you want to do WHAT! HaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHa

I really should move this into Geek's Lounge because its so funny -- you got to be joking, right? HaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHa HaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHaHa

VilePlecenta commented: meh +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Look at your function getData(). It isn't reading the data from the file -- all it is reading is two numbers called low and high. What its supposed to do is read all the numbers into the array temp. You will have to add a loop so that it can do that.

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

This works for me

#include <vector>
#include <string>
using namespace std;


typedef std::vector<string> String1D;
typedef std::vector<String1D> String2D;
typedef std::vector<String2D> String3D;

int main()
{
    String3D vector1;	
    String3D::iterator OneDStart = vector1.begin();
    String3D::iterator OneDEnd = vector1.end();
  
    for ( ; OneDStart != OneDEnd; OneDStart++ ) 
    {  //1D
        String2D::iterator TwoDStart = OneDStart->begin();
        String2D::iterator TwoDEnd = OneDStart->end();
        for ( ; TwoDStart != TwoDEnd; TwoDStart++ )
        {   //2D
            String1D::iterator ThreeDStart = TwoDStart->begin();
            String1D::iterator ThreeDEnd = TwoDEnd->end();
            for ( ; ThreeDStart != ThreeDEnd; ThreeDStart++ )
            {   //3D


            } //1D
        } //2D
    } //3D
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1) The while statement is incorrect

while( inData>>lastname>>firstname>>identity[number] )
{
   // other code here
}

2) you don't want that i loop because it is attempting to read (rows*cols) number of numbers for each name. All you want it to do is read the columns for each name.

int i = 0;
while( inData>>lastname>>firstname>>identity[number] )
{
     sum = 0;
     for(j = 0; j < cols; j++)
     {
          inData >> numbers[i][j];
          sum += numbers[i][j];
    }
    cout << sum << "\n";
    i++;
    number++;
}

3) you are keeping all the integers and floats in an array for all names, but you don't keep the names ? Any reason for doing that? If you don't need the names then why not just toss the numbers for those names too?

4) rename either number or numbers to something else because they are confusing.

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

try this to see if it works. Its ok on my computer

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

BOOL CALLBACK mFindWindowOnlyByCustomTitle(HWND hwnd, LPARAM lParam)
{
    char buf[256] = {'\0'};
    
    ::SendMessage(hwnd, WM_GETTEXT, 256, (LPARAM)buf);
    std::cout << "\"" << buf << "\"\n";
    return TRUE; // process more windows
}
int main()
{
BOOL vFound=((::EnumWindows(mFindWindowOnlyByCustomTitle,0)));
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Its impossible for anyone to actually test the code you posted, so create a small test program that contains only that function, main(), and any other supporting functions to make it compile and testable. Otherwise we're just sooting in the dark about whats causing the problem.

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

>>::ZeroMemory(buf, 256);
Since you declared buf as TCHAR you need to use the sizeof operator, like this: ::ZeroMemory(buf, sizeof(buf)); >>strlen(buf)
Can't use strlen() in TCHAR because it won't work when compiled for UNICODE. Use the macro _tsclen() instead, which will get correctly converted to either strlen() or wsclen(), depending on UNICODE setting.

Note: If you don't want to compile for UNICODE then don't use TCHAR.

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

>>and if i do not enter anything and press enter a message should display saying enter somevalue

Put on your thinking cap. Don't you see where you can add that message to the code snippet I posted? Have you learned about if statements yet?

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

Click on the Welcome Guide at the top of every page and you will get a tutorial.

peter_budo commented: That is correct too ;) +9
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I wanted online tutorial or classes

Then you should have said so. Online tutorials are generally terrible, many of them are very old and teach non-standard code. While other tutorials are just flat out wrong.

The best solution is to buy a good programming book from your local book store or online at www.amazon.com. A discussion of good books to buy can be found in one of the Read Me threads at the top of this c++ board.

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

>>anyways please tell me how to do it....
I thought I already did.

std::string input;
int value;
while(input == "")
{
    cout << "Enter something";
    cin >> input;
};
// now convert to integer
stringstream sstr(input);
sstr >> value;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1) I'm not sure either, but probably the limit of an integer. See limits.h for that value.

2) you don't need to use clear() at all. getline() will do that for you unless it fails, such as at end-of-file. And you don't need to use clear() on sstrm either because it is destroyed and recreated on each loop iteration.

3) see #2

4) getline() doesn't read 4mg file all at one time, but only until it encounters '\n' (or in the case of MS-Windows "\r\n" pair), which is more than likely less than 100 or so bytes. get() will read just one byte at a time, which means you will have to write your own version of getline().

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

looks like you are attempting to use GNU library non-standard time functions. See this article how to use it.

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

There really is no way to tell if the file is still opened other than attempt to open it in your program. If open fails, wait a little bit then try again. stay in that loop until open succeeds or some timeout value expires.

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

depends on whether its a string or numeric value. If you code it to always enter data as strings then you can easily test for empty string, then convert the string to some numeric value if needed.

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

After six months he's back, and he claims to be you, Ancient Dragon (see post 44 below).

I don't know why he said that, but it isn't true. I couldn't insult people like he did, and I doubt he could keep from doing it either.

John A commented: Nice try, but you still can't hide the fact that you are, in fact, DaWei. +15
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1) Depends on the compiler and whether you compile the program for debug or release. Most modern compiler will make them the same code, despite the errors in the code snippets you posted.

2) Speed has nothing to do with it -- the { and } are there to block lines of code. I like to use { and } even with one liners for readability and ease of future enhancements.

3) One is not more efficient than the other -- is readability and maintainability that counts. Use boolean true/false whereever it makes sense to do that.

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

Post your attempt(s) to solve the problems.

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

Either the file isn't where you think it is or you have the wrong filename. Use Windows Explorer to find how where the file is located and its exact filename, including any extension. Does the file have *.txt extension? If yes, then you need to add that to the filename in the open statement. I ran your program and it opened the file ok for me after correcting the filename.

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

- A program that draws a rectangular rectangle using 6 asterixes (*) in its base
- A program that determines if a number is pair or odd (using operator module)
- " " if the largest number inserted is a multiple of the small one (using two numbers).

Those look like three different programs, so I would write them as separate programs instead of trying to put them all in the same program.