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

Damn! I never could beat that game.:sad:

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

you could google for your question. Here is one way to do it. And another here.

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

what makes you think this is a c++ program? I don't see where the OP mentioned it.

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

solution:

int* array = malloc(10 * sizeof(int));

	MyFunc(&array);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

like I mentioned in my previous post, printf() family of functions, which includes ssprintf(), will convert int to hex using "%X" . Example:

char buf[20];
int i = 16;
sprintf(buf,"%x",i);

If you use that in dek_hex() you will have to change the return value from char to char* because as you can see from the above code snippet the hex value is an array of characters, not a single character value.

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

I must implement the function with "**" and I must use an array like int int_array[10];, it is possible to send the array to the function?
Any Ideas?
Thanks

Not possible. MyFun() expects a two dimensional array of integers, not a one dimensional like you are attempting to pass. Not only that, but MyFunc will crash big-time because you are not passing the max number of elements in each dimension of the array. When the array has fewer than 10 rows MyFunc() will be scribbling all over memory.

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

If you are talking about assembly code -- yes but it must be in-line assembly code. Here is an example C function with inline assembly.

int foo()
{
   _asm
   {
       // put your assembly code here
   }
}

>>you need MS Visual Studio to compile it
no you do not need Visual Studio. There are lots of free assemblers.

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

cabel
$60.00 USD / month for 5 computers

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

if you can't use a std::map or std::string, then you can use two string arrays and replace that switch statement with a simple loop, something like this:

char *state_abbr[]= {"AL","OK",... , NULL}
char *state_names = {"ALASKA","OKLAHOMA", ..., NULL}
...
...
char *abbr = "OK";
for(int i = 0; state_abbr[i] != NULL; i++)
{
   if( strcmp(state_abbr[i],abbr) == 0)
   {
         // found it!
         cout << state_names[i] << endl;

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

you can find the maximum and minimum values for any POD (Plain Old Data) types in the file limits.h that is in your compiler's include directory.

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

from the list of filenames it appears you are trying to build a win32 program but created a console project instead of a windows project. If that is true then the easiest way to correct the problem is to recreate a new windows project then copy your files into it.

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

you can use fscanf("%d", ...) to read them into an int memory, and fprintf("%X" ...) to write them back out as hex.

Sin-da-cat commented: Way too nonchalant and broad. +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I only have two e-mail accounts -- one at home and another at work. I rarly keep them beyond a couple days. Why keep all that junk that will never be read again?

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

Use LVM_GETITEM or ListView_GetItem message to get that structure, but you probably already know that. I don't think you need to use virtual arrays if your array size does not change. The lParam member of the structure is set to the row number in your array.

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

Ok, what help do you want? what do you not understand about the requirements ?

Google has lots of help on binary search algorithms. The idea is quite simple -- start in the middle of the array and keep dividing the array in half until you either find what you are searching for or it does not exist. Most of those google links will explain the algorithms and provide examples.

As for sorting? I have never used recursion to sort an array. But there again you can get lots of help from google. if you just take the time to study them.

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

are you using MFC CListView class? or CListCtrl class? the InsertItem() method returns an integer that is the ID for that item. You can then call SetItemData() to connect the row number of your array to that item. Then when the user selects an item your program should call GetItemData() to retrieve the array row number.

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

Please Help

... does that really mean

Please write my program for me?

I don't see a question in your post.

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

name variable in Player class is an uninitialized pointer and the constructor does not allocate any space for it. Why don't you using std::string class instead of char* -- it will make your life a whole lot easier, your hair will not turn grey as quickly, and will greatly simplify the Player class constructor.

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

C or C++?

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

>>printf("%p", letter);
This produces undefined behavior. "%p" expects the parameter to be a pointer to some object, but you are passing the value of a character.

Garbage in, garbage out.

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

Is there a question somewhere ? Or do you just like to post code?

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

you need to talk to your school counseler about what those two tracks involve, but my guess is that computer science will prepare you for graduate school. Which one you should take depends on your goals.

You will probably get better jobs and salaries by getting a Master's degree. The job market is now pretty full of people with bachelors or less degrees.

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

Here you go. google will find other links too

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

just write a small program that will append egavga.bgi to the end of the .exe file. Then when the .exe file starts up have it copy that to the bin directory that your program will also probably have to create.

Or, another alternative is to use an install program, something like InstallShield, that will put all files in their proper places.

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

The extraction operator >> does not read past white space (spaces and tabs). So if the name in the file contains a space your program can not work.

you should replace " while (!myfile.eof())" with this:

while( myfile>>number>>name>>DOB>>sex>>residence )
{

}

Reason: eof() does not detect end-of-file until an attempt has been made to read something. That causes the loop to run one too many times. The ifstream object will return 0 (NULL) when it reaches eof, so the loop above will not execute the loop when eof is reached.

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

One method: append the driver to the end of your exe program (after the program has been compiled), then when your program starts up have it write that out to a file. I did something like that once and it worked. The last 4 bytes of the exe was an integer that represented the size of the file that was appended to the exe file, which allowed the program to know where in the exe file to find the file.

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

>> CMP <------- is this where it goes?

you need to specify what is being compared, two registers ? example:

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

you are right, see the example here

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

google for "c++ map". Here is one example

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

did you read WaltP's comments ? Please answer his questions instead of just repeating the peoblem.

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

you could use a map c++ container.

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

And as a final reason, it's no longer being updated. While Dev-C++ IDE isn't either, you can download MinGW patches for it.


Tubo Tols is back!
Borland released a new version just a couple months ago, but I don't know what its like.

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

Also TurboC programs quickly run out of memory which makes it a poor compiler for all but the simplest graphics programs. And that was the major reason why Mkcrosoft abandoned MS-DOS operating system.

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

If you use google you might be able to find a calculator program. Otherwise, please follow the links in my signature.

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

I took out the push's and pop's because they really didn't not have any effect on the code.

I got into the habbit of pushing all registers that I want to save before calling any interrups or functions because (1) general purpose registers ax, bx, cx and dx are subject to change without notice and (2) you don't know if the function or interrupt called will change them. Better safe then sorry.

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

Using void usually means it wont return an integer value.

No -- main() will return an int whether you declare it void or not. If you declare it void then main() will return some random unpredictable integer.

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

I would think it will be more important to buy really good speakers. Music heard through cheap speakers or cheap set of head phones will sound crappy no matter what sound card is installed.

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

xor ax,ax
is the same as this
mov ax,0
except that xor is a tiny bit faster

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

I think you can use sprintf()

__int64 big_number;

sprintf((LPCTSTR)pi_sString, "%i64d", &big_number);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I think it should be something like this -- I didn't assemble or test it.

;
mov  bx,1 ; row counter
loop_start::
xor cx,cx ; column counter
l1:
 mov al,'*'
mov ah,0eh ;prints to screen
int 10h 
inc cx
cmp cx,bx ; have we printed enough stars ?
jne l1  ; no, then do it again
:print CR/.LF
;
; save our two loop counters
push bx
push cx
mov al,10 ;line feed
mov ah,0eh
int 10h 
mov al,13 ; CR
mov ah,0eh
int 10h
; restore our two loop counters
pop cx
pop bx
; process row counter
inc bx
cmp bx,5
jne loop_start
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you need two counters -- the first counter counts the number of lines to be printed, the second counter counts the number of stars that are printed on the current line. Your code is putting a CR/LF after every star. This should happen only after the stars have been printed on the current line. You need two loops and two counters to accomplish that.

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

I guess we are all going to beat up on that guy

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

It's best if you just ask the manufacturer of that board. Not very likely anyone around here knows the answer.

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

>>why use these directives?what do they mean?
what directives? on lines 1, 2 and 8? those are called "guard tags" to prevent duplicate declarations if the header file is included more than once. The preprocessor will just ignore the file if it has already been processed. Most of the header files you see nowdays use that technique -- many examples are in the header files installed with your compiler.


>>why in main i include only the header file?how does the compiler know where to find find the implementation file
When you have a project with more than one file you have to tell the compiler's linker what object files have to be included to make the final program. The final executable is made up of either object files (with *.obj files in MS-Windows or *.o in *nix) and the libraries.

If you are using an IDE in MS-Windows environment, such as Dev-C++ or VC++ 2005, then you initially create a project which will contain all the *.cpp and *.h files needed to build the program. And you also have to tell it which libraries to include.

>>it would seem more logical to include the person.cpp file that has a command to include person.h....
that is only for human use, the compiler does not care what *.cpp file(s) you put the implementation code in. And you can have the implementation code in more than one *.cpp file. There is no restriction how you …

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

>>Since inheritance is not supported in C
neither is the new operator and classes.:rolleyes:

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

sounds like a similar problem I am having here

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

my processor speed is 2.5 GHz, so I doubt that is the problem. And I think WPM is up to version 10.0 now -- just upgraded yesterday.

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

Please post the code you wrote -- I left my crystal ball at home this morning. And please read the links in my signature.

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

we might be seeing undefined behavior in those examples. I made the program a little bit more complex by adding a base class and VC++ 2005 produced different results than before

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;
class base
{
public:
    base() {m_xx = 1;}
    int getXX() {return m_xx;}
private:
    int m_xx;
};

class My : public base
{ 

   public:
      int a ;
} ;
 
int main( )
{
    My* first = new My ;
    My* second = new My() ;
   
    // this will print out junk i.e. uninitialized value
    cout << "value of var init without round brackets : " << first->a << " " << first->getXX() << "\n";
   
    // this will print out 0 i.e. initialized value
    cout << "value of var init with round brackets : " << second->a << " " << second->getXX() << "\n" ;
}

results

value of var init without round brackets : -842150451 1
value of var init with round brackets : -842150451 1
Press any key to continue . . .

Don't count on () version initializing POD data because it might not. If you need them to be initialized then write a constructor that will explicitly do it.

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

please post exact error message. And read my previous post for suggestions to correct some of them. Yes, we already know there is a syntax error with function division_input . Now you need to figure out how to correct it.