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

>>procedure end idea
Huh :-/

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

Interesting article about the Flat Earth Society. I'll bet they are also creationists who believe the earth is only 6,000 years old. Both turn a blind eye to scientific fact.

As for 9/11 -- my bet is that Bugs Bunny and Daffy Duck were behind it. They probably hired the Gremlins to do their dirty work.

christina>you commented: ;) +21
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

LOL nice one, have to get one of those battery upgrades :)

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

The most common, and recommended, way of coding the message loop is like below, which was generated by VC++ 2005 Express when I created a windows project. Note that it is not necessary to use a break at all.

// Main message loop:
	while (GetMessage(&msg, NULL, 0, 0))
	{
		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That's still only one level of nesting -- two levels of nesting would be something like this:

if condition 1   // first nexting level
{
   if condition 2  // second nesting level
   {
     // do something
   }
} else if condition 3  // back to 1st nesting level
{

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

Did you post the EXACT question and code because that code will not compile due to several syntax errors.

>>What will be printed if the user enters “Wingding”?
Nothing because there is nothing in the program to accept anything from the keyboard.

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

The program will not stop if there are still keystroks in the keyboard buffer, such as if you previously called scanf() to get an integer the '\n' will still be in the keyboard buffer. But you will have to post your program for anyone to give you more help with this.

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

>>but the way it operates is it takes the char* and auto-increments the pointer
No it doesn't -- new operator does not do anything to the pointer.

sizeof operator is always predictable and returns the size of the object, not that the object contains. The size of a pointer is always a constant value regardless of what it points to. The size of a char array (not a pointer) is however much memory was allocated for the string.

char *ptr = "Hello World";
char array[] = "Hello World";

In the above, sizeof(ptr) will always be 4 (32-bit compilers) because that is that is how many bytes are needed to store the address. sizeof(array) however will be 12 because there are 11 characters plus the null terminator. Note that pointers and character arrays are not the same thing.

strlen() on the otherhand actually iterates through the memory address of the pointer and searches for the first null character then returns the length of the string. This will be the same for both examples I posted above.

>>I your opinion, what would be the correct way to stuff the char* with input ? A c-style?
Line 10 in the code you posted is ok, but you need to allocate memory as in Bench's example.

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

Of course it didn't show anything because you have to add a line or two to print the value of the variables to the screen, something like this:

cout << "x = " << x << "\n";
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>what do you think will happen to the values of x, y and z?
why don't you just compile and run the program then you can find out for yourself instead of guessing.

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

Lines 1 and 2 only allocate one char of memory. Any attempt to use strcpy() on either pointer will normally cause memory corruption because strcpy() adds a '\0' to the end of the string that it copies. Line 4 will most definitely corrupt memory because you told getline() to accept up to 10 characters when in fact only 1 character was allocated.

Line 8: yes it causes both pointers to point to the same memory location, thus the memory allocated in line 1 is tossed into the bit bucket and a memory leak occurs.

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

You should not hardcode the size of the name array as shown on line 18 but use the sizeof operator so that if you change the size of the array you don't have to worry about changing it in more than one spot.

cin.getline(newcustomer->name, sizeof(newcustomer->name));

or like this

cin.getline(newcustomer->name, 
   sizeof((struct customerType*)0->name));
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It sort of sounds like the program is hitting that case statement twice. Put a print statement in each of those if statements to see how often it goes there -- or learn to use your debugger and put a break statement there. We can't really tell you much with such a small amount of code.

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

>>There are if start=1 statements

Please post that exact code -- what you posted is an assignment statement, not a boolean logic statement. use == instead of = to test if start is or is not 1. C, C++ and C# require two equal symbols to test for equality, VB and a few other languages use only sigle = statement. If you are coming from VB I can understand your confusion.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
newcustomer=new customerType;
cout<<"Please enter a name: ";
cin.ignore('\n');
cin.getline(newcustomer->name,21,'\n');

for example of what it does say I enter "john smith" minus the quotes, the output on the screen is just the 'h' at the end of smith nothing else.

post the customerType structure -- how did you declare name? Since this is c++ why don't you use std::string instead of char*?

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

Can't you instead use gets() function?

No -- gets() is C not C++ and its terrible to use in C code too.

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

The function that is being called requires wchar_t* instead of char* when compiling a program for UNICODE. Typecasting will not make the conversion. Instead you should be using the macros provided in tchar.h to make the conversion. when compiling for UNICODE all character string literals need to be surrounded with either _T( "string literal here" ) or _TEXT("string literal"); Character arrays need to be declared with TCHAR macro instead of char* ( or UCHAR* in your code snipped), for example TCHAR* buffer . All the string manipulation functions in string.h also have UNICODE equivalents and you should use the portable UNICODE version as shown in MSDN, such as _tcscpy() instead of strcpy().

Killer_Typo commented: cool +6
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

is this what you are looking for ?

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

Changing the order of the items is what the OP wants to do.

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

Lady Bird Johnson, widow of former US President Lyndon B. Johnson died today at age 94. Her lagecy was to rid our interstates of billboard proliferation and planting wild flowers along hiways/interstates. That is the most any First Lady has done since her time. We in USA are all better off today because she was First Lady for a few years.

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

Can't help you because we can't see your monitor -- too far away from where I am sitting :-/ So if you want any help you will just have to post code, and please use code tags.

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

The default class constructor is always called then the c++ class object is declared (except as noted below), for example on line 25 of the code you posted. On line 29 the class's operator= method is called, not the class constructor.

The second example you posted works the same way except its all on the same program line. Hint: whenever you see '=' operator you can be sure the class's operator= method gets called. But if you code it like below then only a constructor is called. String s1(xstr);

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

Yes, LB_INSERTSTRING will work if all he wants to do is insert the new item in a specific location.

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

> "talk really nice and white." Hmm.. Whatever could you mean by this.
An expression I use for 'act like an angel'.
:P

In USA that is a racist remark meaning only white people are nice people, and I'm sure you didn't mean to say that.

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

And one senitor from the state of MA who I will not mention by name should have been jailed for manslaughter some 30+ years ago.

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

>>Any suggestions would be greatly appreciated

Yes, please post code

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

Why would he want to use LB_SETITEMDATA ? That will not change the order of the items that appear in the list box.

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

arrays are transferred by value to a function,

Not really -- only the pointer is passed by value, all data is passed by reference, that is, the data is at the same address location in both the calling and called functions. You can not pass array data by value in c language which would imply that the data is duplicated when passed to the calling function.

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

The CWinApp-derived class contains a list of CDocTemplate objects. You can iterate through that to find the pointer to CDocument class. From CDocument iterate through the list of CView classes that are attached to the document. I know this seems a long way around to get to the CView class but I think its the only way from CMainFrame.

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

File-->Open, File-->New, etc have to be implemented in the CWinApp-derived class, not CMainFrame.

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

Microsoft did away with the Class Wizard that was in VC++ 6.0 and replaced it with Properties windows. In ClassView right-click a view and select Properties from the popup menu. Or if you have a dialog box displayed right-click a control and select Properties. If you want to create a name for a control right-click on the control and select Add->Name (I think). Its a lot different (and I think more difficult) than it was in 6.0 ClassWizard.

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

I would think that would be next to impossible to do without knowing the commands to send to the web site since every web site is different. You'd probably have to download the page that contains the user id and password edit boxes, parse it, and pass back whatever it is supposed to return to the server when the submit button is pressed. I'm not a web programmer so I don't know much more than that about it.

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

I think you will have to avoid system() wherever possible because some commands such as set won't work correctly.

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

well im 17 n she is 16

She's jailbate -- don't let your little head rule your big head. Forget her and find someone closer to home (and a little older).

maravich12 commented: Funny...but true +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't think CListBox has a method to move a row from one spot to another. If you want to change the order of the items then I'd probably copy them all into a std::vector<std::string>, sort the vector however you want, delete everything from the list box, then copy the vector back in the order you want.

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

>>while (!infile.eof())
This is wrong -- don't use eof() because it doesn't work the way you would think it should. Here is a better way of doing it

while( infile >> name)
{

}

>>if (i < name.length())
In your code the value of i (which you initialize to 0) will NEVER ever be less than the length of name, even when name is an empty string.

If you want to check the first character of name against any character is a specific string

std::string teststring = "ABCFPNRT"
if( teststring.find(name[0]) != std::npos)
{
   // found it!
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

just write a little prgram that generates 1000 numbers between 10 and 100 using rand() % 100 + 10 to generate the numbers and save them to a file. Then you can write the other program as your teacher instructed.

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

>>i want to close this dialog box after a particular thread ends
That sounds like there is more than one thread in your dialog application program.

Do NOT call AfxEndThread() because you didn't call AfxBeginThread(). If you want the dialog box to exit immediately after processing OnInitDialog() then just simply call EndDialog() at the end of that function.

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

What is jaywalking? - and why s it illegal?

I have not heard of anyone getting so much as a ticket for many years, but a google search showed this recent arrest. And another version of the same arrest here.

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

If you wrote both programs then you could use (1) Clipboard, (2) Pipes, (3) sockets (4) COM objects. The simplest to implement is the clipboard. If you would tell us more detailed information such as (1) did you write both programs (2) if not then how does the program save the data that you want.

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

In that case have the thread that is closing call PostThreadMessage() to send a private message to the DialogBox thread, then in the dialog's PreTranslateMesssage() event handler check for that message and call EndDialog().

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

Any reason for posting all this nonsense code ?

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

you could set a timer and close the dialog box in the OnTimer() event handler. There may be a couple other options: (1) send a WM_CLOSE message from another window or (2) click the X button in the upper-right corner, assuming you have not removed that too.

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

what operating system?

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

And others will give you 6, 6, 5 like it should be.

that may be the way we humans think about it, but not compilers.

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

The correct answer is that the result is undefined, or unpredictable. It depends on the compiler -- the answer by some compilers may be 5,5,5 because only the last version is stored. Yet other compilers, such as VC++ 2005 Express will give 6,5,5.

Aia commented: Thanks for explanation. It opened some good teaching time. +6
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'm back now -- a day earlier than originally expected. Had a great time visiting people I had not seen for so many years. There were about 500 people at the reunion.

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

moved -- this is not a programming problem.

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

Since gradeAvg is the average for the student just read, put that statement immediately following the while keyword -- you will have to add braces around the while loop because it will now be multiple-line controle.

while( infile >> <snip> )
{
    int gradeAvg = ...
    if(gradeAvg>=90)
    {
         <snip>
     }
}