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

>>And I also know that it's not allowed to declare functions in headers unless they are inlined

Wrong -- see your second example.

>>Will it still be inlined?
No (assuming lines 6-16 are in a *.cpp file and not *.h; there will be lots of other problems if you put that code in a *.h file).

>>And is there a keyword to explicitly specify to make any function not-inlined?
No. The default is not inlined. A method is only inlined if you explicitly ask it to be with the inline keyword or by coding it as in your first example. Even then there is no guarantee that the compiler will inline the code, inline keyword is only a HINT to the compiler, not a requirement.

sergent commented: thanks +7
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

but you could edit out the link as he asked.

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

cin is getting an error on the first character because it is not numeric digit. You declared variable character as int, so cin expects to read numeric digits. Change the data type of character to char and it should work as expected.

Suggestion: Change the while loop to read all the characters in the file

while( cin >> character )
{
   cout << character << endl;
   ++count;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>is it not safe to assume the following?

No. You could typedef s16 = long if you want to.

>>could you not just use the defined values for windows C, and if need be, the type definitions in "windows.h"

No because windows.h does not define those either.

>> instead of using a cross compiler
Code::Blocks is not a cross compiler. It won't generate code for another computer architecture. AFAIK Code::Blocks is only supported on PCs with IBM/compatible processors.

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

Microsoft compilers do not define s16, s32, or u8 so you would have to typedef them yourself if you want to use their compiler. I think the best compiler for you would be Code::Blocks and MinGW compiler, which is supported on by *nix and MS-Windows. MinGW compiler has already ported most *nix libraries to MS-Windows.

>>It's common to assume when coding for *nix that you can rely on POSIX compatibility;
MS-Windows is not POSIX compatible.

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

>>With the two additions, it skips to the end after I enter the number of numbers

Because scanf() leaves the Enter key '\n' in the keyboard buffer, and fgets() stops reading at the first '\n' it encounters. Call getchr() after scanf() to remove '\n' from the keyboard buffer.

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

line 54: for(int i=0; d != 400; i+10)

The condition d[i] != 400 is never met. Probably should be i != 400 or better yet i < 400

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

That was my original thought too, but I dismissed it because it would be horribly sloooow.

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

The while statement on line 54 is not going to work correctly because it will cause the lzst record in the file to be read twice. One way to fix that is like this:

int numRecords = 0;
while( ReadRec(inFile, site) )
{
   ++numRecords;
   // blabla
}


ifstream& ReadRec(ifstream& inFile, webRec& temp)
{
   inFile >> temp.url >> temp.revenue >> temp.hits;
   return inFile;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> Is there a way to get these numbers to have zeros prefixed to them?

Not that I know of

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

You can sort the vector without splitting it. call std::sort to do the sorting. All you have to do is to expand the resource number from 1 to 2 digits, such as "resource1" to "resource01" when you read them from the file. That way std::sort (or any other sort algorithm) will sort the vector correctly.

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

Your program seems to work correctly for me on Windows 7 and using VC++ 2010 Express.

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

line 25 is using the wrong variable. display TEXT, not search.

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

Not all 255 possible ascii characters are printable and you will just see blanks or funny looking squares for them. Here is one way the table should be printed.

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

Nope, cleared cache - still nothing doing. I'm stuck in DW! In all of my browsers! And my smartphone.

Uninstall MS-Windows, reformat the hard drive, then reinstall MS-Windows. That should do it :) (just kidding)

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

>> When you log out you should see this screen

It does. Unfortunately when I re-visit Daniweb after that screen, I'm still logged in.

I just tried it and had no problems. Logged out, closed browser then started again. I had to log back in. Maybe you need to clear your browser's catch (that's always Dani's answer to me, which almost always solves the problems).

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

I like that change too. :)

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

Windows 7, Google Chrome. No problem logging out. When you log out you should see this screen

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

You are correct, I didn't read it well enough.

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

The problem is line 8 of the header file. Delete that semicolon at the end of the class name. Otherwise it looks to be ok.

>> it is generally inadvisable to have code (as opposed to declarations) in a header file
He has inline code, which is perfectly acceptable and often used in professional programs. One or two inline statements within the same method is ok, more than that should be moved to a *.cpp file and only function declaration in the header file. The reason for doing that is to reduce the overall size of the program. The compiler may duplicate all the code of inline functions every time the function appears in the program. So if a program calls foo.Example() 10 times then all the code in Example() will be duplicated 10 times. Clearly 1 or 2 statements in the inline method will not be a problem, but more than that could potentially cause unnecessary bulk. I say potentially because compilers are free to ignore inline keywords and statements if they so desire.

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

we already told you how to fix that problem. Go back and read previous posts.

>>Using new same error happens :
The code you posted is the same as your original code, so you made no changes at all.

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

Change the packing factor to 1 and the alignment problem will go away. #pragma pack(1) will not put holes in the structure. The pragma is compiler dependent, some compilers may do it differently.

#pragma pack(1)
// your structure goes here
#pragma pack() // revert to default
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Unlike C, C++ requires you to typecast the return value of functions that return void*, like malloc().

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

Those numbers have nothing to do with the amount of memory occupied by all those strings. Its nothing more than the starting memory address of them. If you want to display the length of the strings then you have to call strlen(), such as printf("%d\n", strlen(argv[i])); [edit]Oops! What ^^^ said :)

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

Can't say because we don't know what library is loaded or what symbols are exported from it

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

Look at the string you are passing to LoadLibrary(). You are passing it the path but not the name of a library.

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

You need to learn how to use your compiler's debugger so that you can single step through your program and find out for yourself what is causing the problem. That will save you lots and lots of time

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

The first parameter to WinProc() is the handle to the window to which WM_LBUTTONDOWN event was sent.

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

i dont know about C/C++ but in C#/Java/VB (.NET Appis) mouse events work only in form, i mean it wont catch any event out of program, also if use your method the focus will be lost and simply program will stay stand by and will not do any action i think...

C/C++ can grab mouse events globally by installing Windows Hooks

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

>> I would like to write code which takes an action every time a person clicks inside of the second window (picturewind) but not when the person clicks in the first window (hWnd)

Its a little unclear what the above means. In which program is the actions to be taken? If in the second window then its just standard mouse events. But if you want to do something in the first window when the mouse is clicked in the second, then its just slightly more complex. In the second window capture the mouse events as before but send a message to the first window letting it know about the events.

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

You need to capture one of the mouse events, such WM_LBUTTONUP On that page in MSDN you will also find links to all the other mouse events that you will want to study.

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

On networks you also have to consider endianness If one computer is big endian and the other little indian then the numeric data will have to be converted.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
temp =  ArrOperand[counter];
	static_cast<char>(temp);
	perm[i] = temp;

Why all that hard work??? All you need is this: perm[i] = (char) ArrOperand[counter]; -- that is, assuming the values in ArrOperand can be held in a char variable. If not, then it won't work.

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

>>}while(choice != 'n' || choice != 'N');

You need to use &&, not ||.

Clinton Portis commented: oopsie +10
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

call recv() twice, the first time to get just the first 4 bytes (assuming the size of the structure is at the beginning, and then again to get the rest of the structure.

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

line 19: use == (comparison) operator instead of = (assignment) operator

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

You have already stated the items in the combo box -- Day, Afternoon, Night and Mixed. Do you know how to add those items to the combo box while in Form Designor? (In the comboBox Properties page scroll down to the Items Collection and you can add them there. See thumbnail below)

In the Calculate button's SelectedIndexChanged event handler

private: System::Void comboBox1_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
			if( this->comboBox1->Text == "Day" )
			{
					 // do calculations for Day here
			}
			else if(this->comboBox1->Text == "Afternoon" )
			{
					 // do calculations for Afternoon here
			}
			else if(this->comboBox1->Text == "Night" )
			{
					 // do calculations for Night here
			}
			else 
			{
					 // do calculations for Mixed here
			}

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

You can not make the results of the C program permanent on the terminal. Like all other shell programs anything done within the program (or shell script) is destroyed when the program ends.

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

copy the DLL into any of the folders listed in the PATH environment variable and it will work regardless of where the application program is located.

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

I don't ever use malloc() in a c++ program, its just too confusing to mix malloc() and new together in the same c++ program. Stick with new for consistency and to be less error prone.

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

Activate the ListBox's SelectedIndexChanged event (use listBox's properties window to do that) and the IDE will generate a function for you, then just do this:

private: System::Void listBox1_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
				 textBox1->Text = listBox1->Text;
			 }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you are still not specific enough. Do you have a win32 program or c++/CLI Windows Forms program?

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

Depends on what you are programming? *nix? MS-Windows? QT? there are lots of others too. You need to be a lot more specific about what you are coding.

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

Simple solution -- each time the program starts it updates the key value with a new value. Call RegQueryValue() to get the current value, increment the counter, then RegSetKeyValue() to update it.

Call these functions in the order listed. You will have to do error checking to insure they succeed.
RegOpenKeyEx()
RegQueryValue()
RegSetKeyValue()
RegCloseKey()

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

maybe you needed to clear your browser's catch. Usually works for me.

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

>>Yes I have an old fashioned phone
:) Here is an old fashioned phone

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

Depends on where you live and what kind of landline phone you have. I have a cordless phone and the phone number shows up on its display. But you will have to get with the manufacturer of your phone to find out how it works.

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

Here is an example of how to create a key. Make sure you read the Remarks section of this link

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

int main(int argc, char* argv[])
{
	HKEY hKey = 0;
	DWORD dwDisposition = 0;
	long retval = RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Ancient Dragon",0,0,REG_OPTION_NON_VOLATILE,
				KEY_ALL_ACCESS,0,&hKey,&dwDisposition);
	if( retval !=  ERROR_SUCCESS)
	{
		char buf[255] = {0};
		DWORD dwError = GetLastError();
		FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,0,dwError,0,buf,sizeof(buf),0);
		cout << buf << '\n';
	}
	else
	{
		RegCloseKey(hKey);
		cout << dwDisposition << '\n';
	}
	return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

To copy to another location, open the file in binary mode then read/write 255 bytes at a time until end-of-file is reached. Another way to do it on MS-Windows is call win32 api function CopyFile()

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

Maybe you should be reading a tutorial