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

Apparently that doesn't work because I've never seen even one tutorial. I don't even see a link for tutorials

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

I think it might help if we were allowed to post tutorials instead of linking to the ones on other sites. Posting tutorials seems to be an impossible task since there is no thread in which to post them. On PFO there are tutorial forums. They require mod approval but at least members know where and how to post them. There is no such mechanism here at DaniWeb.

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

You need to pass the string by reference, not by value. string login(string& pfile); or you can catch the return value in main pfile = login(pfile); When you do that there is no reason to have a parameter to login().

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

Yes, really.

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

If that last line is executed instead of any of those if statements then the line 6 is the obvious problem. have you checked the value of lparam and lparam & 0x80000000 ? And why don't you just simplify that line by using 0x80000000 instead of 1 << 31 ? The compiler could care less one way or the other but it would help you and others to know that mask you are trying to use.

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

you can always draw it yourself however you like it, something like this one

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

See also this thread. You have several options -- just pick one and go with it.

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

What have you tried so far? Have you used google to see if you can get any tutorials? Like this one?

And please, stop using those html tags, they don't work here.

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

I think the explanation in this thread will solve that problem.

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

If the application program is a console program then you may have to have a WinMain() inside the dll and call it from the dll. For example if you have a function named foo() in the dll then foo() would call its WinMain() using HINSTANCE that it gets by calling GetModuleHandle(). You could probably name the function anything you want, I just used WinMain()

Here's an example DLL that I did for this thread. I got some of the code from other threads here at DaniWeb.

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include "mydll.h"

BOOL MakeAWindow(HINSTANCE appInstance,int show);
LRESULT CALLBACK WndProc(HWND window,UINT msg,WPARAM wParam,LPARAM lParam);
HWND MainWindow = 0;

static int*	gInstList	[7]={ 0, 0, 0, 0, 0, 0, 0 };
static int	gInstCnt=0;




int MessageLoop()
{
	MSG msg;
	ZeroMemory(&msg, sizeof(MSG));

	while (GetMessage(&msg, 0, 0, 0))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

return msg.wParam;
}

INT WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance, 
                   LPSTR lpCmdLine,
                   int nShowCmd)
{
	if (!MakeAWindow(hInstance, nShowCmd))
	{
		MessageBox(0, "Window Creation -- Failed", "Error", MB_OK);
		return 0;
	}

return MessageLoop();

}

BOOL MakeAWindow(HINSTANCE appInstance,int show)
{

	WNDCLASS wc;

	wc.style         = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc   = WndProc;
	wc.cbClsExtra    = 0;
	wc.cbWndExtra    = 0;
	wc.hInstance     = appInstance;
	wc.hIcon         = LoadIcon(0,IDI_APPLICATION);
	wc.hCursor       = LoadCursor(0,IDC_ARROW);
	wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
	wc.lpszMenuName  = 0;
	wc.lpszClassName = "wc";

	if (!RegisterClass(&wc))
	{
		MessageBox(0, "Failed to register the window class", "Windows Sucks!", 0);
		return FALSE;
	}
	
	MainWindow = CreateWindow("wc",
                                  "Hello",
                                  WS_OVERLAPPEDWINDOW,
				  CW_USEDEFAULT,
				  CW_USEDEFAULT,
				  CW_USEDEFAULT,
				  CW_USEDEFAULT,
				  0,
				  0,
				  appInstance,
				  0);

	if(MainWindow == NULL)
	{
		MessageBox(0,"Function CreateWindow() Failed",0,0);
		return FALSE; …
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>It means somebody is waiting for someone to reply.
No it doesn't mean that at all. Many times the original poster will make a final post just to say "thanks" to all other posters, then leave without marking the thread solved. So IMO a new link for this purpose would really give you unusable list of threads.

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

look at the argument list for the function fun() -- it requires three parameters; two integers and a char*. Now look at how you are trying to call that function in main(). It is only passing one parameter instead of three.

This compiles correctly with vc++ 2010 express. Note the last dimension must be 6 instead of 5 because "13.40" requires 6 bytes including the null terminator.

const char var[][2][6]={ 
    {"1.95","3.70"},
    {"2.40","4.60"},
    {"2.70","5.70"},
    {"6.60","13.40"}
};

void fun(int col,int row,const char *str)
{
}
int main()
{
    fun(0,0,var[0][0]);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

cin stops reading keyboard input at the first space or the enter key. The next time cin is called it will just take whatever is already in the keybord buffer, if anything. call getline() instead of cin to allow for spaces in the string. getline(cin,record[i].Sno);

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

1. The null terminator is a character at the end of the string that contains '\0'. The example you posted could be rewritten like this:

char phrase[13] = {'G','a','m','e',' ','O','v','e','r','!','!','!',','\0'}; Its just a lot more convenient for us to type it as in your example, and the compiler will generate the correct code to null terminate the string.

2. You mean the quotes around [b] "Game Over!!!"[/b]? Yes the quotes are required so that the compiler knows where the beginning and end of the string are.

[edit]^^^ Oops he posted before I did.[icode]
char phrase[13] = {'G','a','m','e',' ','O','v','e','r','!','!','!',','\0'};
Its just a lot more convenient for us to type it as in your example, and the compiler will generate the correct code to null terminate the string.

2. You mean the quotes around "Game Over!!!"? Yes the quotes are required so that the compiler knows where the beginning and end of the string are.


[edit]^^^ Oops he posted before I did.

crapgarden commented: awesome +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you want to support any sql-compliant database then use ODBC, which is the oldest and most common way to access them. There are a few free c++ odbc wrapper classes, just use google and you will easily find them. Also you might want to read an odbc tutorial, which again can easily be found with google.

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

Never use #include to include one *.cpp file in another. If you have two or more *.cpp files then they must be compiled separately and then linked together to create the final executable program.

Your class declaration should be in header files (with *.h extension). You can put them all in the same header file if you wish, or split them up into different header files. For small classes you might as well just put them all in the same header.

To avoid the duplicate declaration error problem you should use header code guards preprocessor directives, as in this example

#ifndef MYHEADER_H
#define MYHEADER_H
// put all your classes and other stuff here

#endif // end of MYHEADER_H
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes it was -- but it ran in protected mode so that it could use all that ram.

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

There is no such thing as a good gui for MS-DOS Version 6.X or earlier. That's one reason Microsoft evolved into 32-bit protected mode programming and wrote MS-Windows operating system. MS-DOS simply doesn't support enough memory to allow for a GUI environment. About the best you can do is flip the screen into graphics mode and draw a few pretty pictures -- and very very slowly.

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

Your compiler is correct. void main() is non-standard, the c and c++ standards require main() to return an int. Change your program to int main() and it will be standards conforment.

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

What forums are you talking about? DaniWeb has no forums devoted to viruses. And any discussion about them might get you banned. You have to be very very careful about what you say of that topic, so its best just to not discuss that topic at all, except maybe to find out how to clear a virus or about antivirus programs in general.

If you have a gripe about a particular moderator, PM ~S.O.S~, Narue, or HappyGeek with your complaint.

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

Its illegal to write viruses -- you can go to prison for that. I would castrate without anastasia those who do that if I could get my hands on them. Me hostile?? No, not one bit.

WaltP commented: I wouldn't use Anatasia either -- the Czar would be mad! +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>*(mpg+ctr) = *(miles+ctr) / *(gallons+ ctr);

That's the same thing as this: mpg[ctr] = miles[ctr] / gallons[ctr]; Personally I do not like or use the pointer arithmetic as shown in your code snippet, but its just a matter of personal taste. IMO using the index method I show is a lot more clear what is going on, and of course requires little thinking about it. Programmers should write for clarity, not cuteness or an attempt to impress others.

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

That is the wrong way to go about clearing the keyboard input buffer. Narue has written an excellent article about that very topic. See this link

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

I always hated bourbons and whiskeys. My favorites were gin & tonic, vodka and kahula (black russian). Ho Hum -- that's what happens when you get old, you have to give up all those things. Now I just drink unsweetened ice tea, diet soda, and bottled water.

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

>>however when i copy the structure definition to my code , it complains its already defined in time.h ?

You are not supposed to copy standard C structures into your code -- juse use the #include <time.h> statement .

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

>>what i was looking for was not allocating the whole ja[15] array structure at the start but only 3 members of it , and expanding as the user enters more

Yes that can be fairly easily done by declaring ja as a pointer and not an array. Each time you use an item of the array you have to increment nItemsUsed.

struct  jatekos* ja = malloc(sizeof(struct jatekos) * 3); // allocate 3 members
int jaSize = 3;
int nItemsUsed = 0;

// now in a loop or something start filling the array
// when the array is full then reallocate it to a larger size
if( nItemsUsed == jaSize)
{
   // bump size by 5 items
   jaSize += 5;
   // now reallocate the array
   ja = realloc(ja, sizeof(struct jatekos) * jaSize);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>@WaltP: It is better, because that's what is the standard:

>>@AncientDragon:
>>I read my own links, and I do not know why did you ask that.

I said that because the link you posted said no such thing. You are attempting to make us believe Bjarne said something that he did not, and that constitutes a flat-out lie.

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

You mean you don't even read your own links ???

A conforming implementation accepts

int main() { /* ... */ }

and

int main(int argc, char* argv[]) { /* ... */ }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1. No.

2. That does not add members to the structure, it declared 15 objects of the structure. A better way to do that is by using an array of structs e.g. jatekos array[15]; // declare 15 objects of type jatekos 3. Ok the code you posted here makes more sense. Here again, like above, you need to declare an array of those structures.

struct jatekos ja[15];

while(getline(tmp,20)>0){
   strcpy(ja[i].nev,temp)
   i++
}

//or like this, eliminating the need for temp array
while(getline(ja[i].nev20)>0){
   i++
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Some compilers may produce warnings if you declare main() with arguments and never use them. Use int main() if your program does not need command-line arguments, otherwise use the version with two arguments.

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

strange -- the only thing the compiler will accept on line 11 is a string literal.

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

The problem is your WinProc() is incorrect. Change it to the one shown in that tutorial link I posted and your program works.

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

Have you read this tutorial?

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

Why disappointing? DLLs never call functions in the application program (except via callback function pointers) -- its the other way around.

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

Read the article I posted carefully and download the demo application files whose link appears at the beginning of the article.

>>Can I call functions in the application with the DLL ?
No. But you can get text off the window and put text into the program. You can also use SetWindowsHook() to hook into the remote process's WinProc() function, which means MS-Windows os will call your WinProc() function before that of the remote process.

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

MSVCR90D.dll is a debug DLL (which is what the D at the end means). Sounds like you are trying to mix files compiled for debug with others compiled for release mode. Calling DLLs compiled for debug may also produce that error.

Here are other suggestions to try

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

Yes of course you can -- that's the whole purpose of doing that. After calling LoadLibrary() to load the DLL into memory you need to call GetProcAddress() to get the address of the function you want to call.

If you want to inject YOUR DLL into another process, then here is a good tutorial

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

Post current code.

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

You would be right if there were enough demand for such an operating system. But there isn't, and hasn't been for many years now. If you want a 32-bit DOS then just use *nix. MS-DOS is dead, so leave is dead and buried.

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

lines 7 and 8 are incorect. Array elements are counted from 0 up, but not including the max index number. For example scores has valid index values of scores[0][] and scores[1][] The <= operator on line 7 will attempt to dereference scores[2][], which does not exist.

The correct code for line 7 would replace <= with just <.

line 10 is also in error. You have to pass a pointer to scores by adding & pointer operator. scanf("%d", &scores[i][j]);

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

Don't you have a brain? Don't use your head for something other than a hat rack.

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

You will have to use two temp arrays

(1) and array that contains the random numbers so that when a random number is generated the program searches this array to see if it has already been used. If the new random number already exists in the array then go back and generate another random number.

(2) You can not shuffel the rows directly into the original array because moving one of the rows will overwrite the values in the destination row, and the values in the destination row will be lost forever. Create a new temp array to hold the shuffled rows, then after the shuffling is complete copy the data in the temp array back into the original array.

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

in a loop check each character of the string to see if it's a digit or an operator. If its a digit then add to a vector of integers, otherwise if it's an operator add it to a std::string of operators.

Since this is probably homework, I'm not going to post the complete solution. You have to write it yourself and post what you have done.

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

You need to get input as std::string then pars it to extract the integers and operators. Since they can be entered in any order there really is no other way to do it.

predator78 commented: exactly, didn't know this to be true with c++ but great info +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Any Advice/Idea!

If you expect the answer you want then you have to learn how to ask the correct question. I answered the question you asked, nothing more :)

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

>>is it possible?

Yes.

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

The error message tells you what you have to do

error C2440: 'initializing' : cannot convert from 'b_t **' to 'a_t *const *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast a_t* const * ref_pa = reinterpret_cast<a_t**>(&pb);

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

You mean you wrote a program with 64-bit compiler and tried to run it on a machine that is 32-bit operting system? That won't work. Compile it with 32-bit compiler and it will work on either 32-bit or 64-bit machines.

Next, you have to probably install the MFC re-distributables. Look in your compiler's install directory and you will probably find them. If not, then look on the DVD that the compiler was on. If all else fails, you can download them from here

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

line 11. There's the easy way to code it. Notice it does not do any seeks() or memory allocations because std::string will do all memory allocations for you.

// Player's Name
  std::string name;
  ifstream CharName("C:\\ZacarasEmpire-Offline\\Data\\File01.ze");
  if( CharName.is_open())
  {  
      CharName >> name;
      CharName.close();

      cout << name;         
      hEditName = CreateWindow(TEXT("STATIC"), name.c_str(), 
        		    WS_CHILD | WS_VISIBLE | SS_LEFT,
        		    40, 190, 100, 23,
        		    hWnd, (HMENU) IDC_EDIT_NAME, GetModuleHandle(NULL), NULL); 
  }