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

depends on the operating system. For MS-Windows, see ExitWindowsEx()

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

I didn't retire from programming until I was 63. Shortly after that I got bored so I took a part-time non-programming job. People who just go out to pasture to "live a peaceful life" usually don't live very long because they fail to keep their mind active. That's one of the tricks to beating dementia and Alzheimer's disease. There are several 80+ year old people working part-time where I work, one woman recently had her 100th birthday.

So to suggest people retire at 50 is nonsense.

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

I agree that a recovering alcoholic can not consume any alcoholic beverages. But for others, an occasional drink of alcoholic beverage is not a problem. The problem is excessive drinking. No one will become an alcoholic by drinking only one drink a day (such as one beer, one glass of wine, or one shot of hard liquor). Even Jesus consumed a little wine occasionally.

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

Its whatever Microsoft says it is. Here is a good explanation of that. The size of a word or dword is assembler dependent, not os dependent.

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

move line 7 down one line so that the color array is not re-initialized on every loop iteration. And you can get rid of that awful goto statement.

int colors[3] = { RED, YELLOW, BLUE };
while(1)
{
    textcolor(colors[rand()%3]+BLINK);
    gotoxy(1,5)
    cprintf("HELLO WORLD");
    delay(100); // slow down the loop
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It might appear to be that way, but employees are allowed breaks once in awhile and that may be what you have observed. We have a break room in the back of the building where customers can't see us lounging around. And yes there are a lot fewer employees now than there was 2 years ago which makes for some occasional long lines at the checkout registers. No employee at WalMart would keep his/her job very long if caught using a cell phone while working.

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

I hate whiskey and bourbons, and margarita -- yuuk. Vodka, gin and Irish Mist are my favorites. A glass of beer with a shot of lime (picked that up in UK), or a glass of champagne with a shot of brandy are pretty good too.

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

I suspect that is reading the file incorrectly. If all the records in the file are of type struct menu then there is no need for 35 to 39. It just boils down to this:

while( infile.read(reinterpret_cast<char*>(&m), sizeof(Menu)) )
{
    cout<<m.idNum << m.foodItem << m.price << m.description <<endl;
}
Salem commented: +1, since the OP didn't bother +17
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is what I mean. Note that variable KeyStroke must be int, not char because it will have a value > 255 for special keys.

#include <iostream>
	#include <conio.h>
/* This program shows how to pick up the scan codes from a keyboard */
	 
	/* These define the scan codes(IBM) for the keys. All numbers are in decimal.*/
	#define PAGE_UP     (73+255)
	#define HOME        (71+255)
	#define END         (79+255)
	#define PAGE_DOWN   (81+255)
	#define UP_ARROW    (72+255)
	#define LEFT_ARROW  (75+255)
	#define DOWN_ARROW  (80+255)
	#define RIGHT_ARROW (77+255)
	#define F1          (59+255)
	#define F2          (60+255)
	#define F3          (61+255)
	#define F4          (62+255)
	#define F5          (63+255)
	#define F6          (64+255)
	#define F7          (65+255)
	#define F8          (66+255)
	#define F9          (67+255)
	#define F10         (68+255)
	 
	using namespace std;
	 
	int main()
	{
		int KeyStroke;
	 
		cout << "Press Escape to quit." << endl << endl;
	 
		do
		{
		    KeyStroke = getch();
                    if( KeyStroke == 0 || KeyStroke == 224)
                        KeyStroke = getch()+255;
			switch (KeyStroke)
			{
				case F1:
					cout << "F1" << endl;
					break;
				case F2:
					cout << "F2" << endl;
					break;
				case F3:
					cout << "F3" << endl;
					break;
				case F4:
					cout << "F4" << endl;
					break;
				case F5:
					cout << "F5" << endl;
					break;
				case F6:
					cout << "F6" << endl;
					break;
				case F7:
					cout << "F7" << endl;
					break;
				case F8:
					cout << "F8" << endl;
					break;
				case F9:
					cout << "F9" << endl;
					break;
				case F10:
					cout << "F10" << endl;
					break;
				default:
					cout << "Some other key." << KeyStroke << '\n';
			}
            
		}while (KeyStroke != 27); // 27 = Escape key …
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

As I said before, when a special key is pressed add the value 255 to the second call to getch() to make the key unique from all other keys on the keyboard. That way your program will always be able to distinguish F1 key from the semicolon, which also has key code of 59.

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

change it to this

typedef struct DictionaryList* Dictionary;
struct DictionaryList
{
char* word;
Line lines;
DictionaryList* Next;
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't drink. Never have. Never will.

You don't know what you're missing ;) You don't have to get lousy sloppy drunk in order to enjoy one or two good alcoholic drinks. But caution: computer programming and drinking don't mix.

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

First you need an array of averages, as you have already coded on line 3. You will eventually want to read those values from a data file and put them into an array, but hard-coding them for now will be ok so that you can finish the rest of the assignment.

The array of grades on line 4 is not needed. Instead, you need an array of 5 integers that will contain the count of letter grades. So if you declare int counts[5] = {0}; , counts[0] is for 'A', counts[1] = 'B', etc.

In a loop for each average, use a series of if statements to determine which grade is appropriate for the given average, then increment the counter element. For example

if( Averages[i] >= 90.0 ) counts[0]++;
else if( Averages[i] >= 80.0) counts[1]++;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

add a line at the end of main() to make the program want for you to press a key

int main()
{
   <snip> // your code goes here
   getchar(); // wait
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Homework? Here is where to start

#include <stdio.h>

int main()
{
   // put your code here
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

did you look in either the Debug or Release folder, depending on which one you compiled? It should have generated by *.dll and *.lib files.

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

I have a FB account, and twitter too, but rarely use them. But I see your point about labs. I'm a PT WalMart cashier and I could imagine what would happen if I brought a laptop to the register and was on FB all the time. When a customer comes to my register to check out I'll tell him "You'll just have to wait a few minutes because I'm writing something on Facebook". FIRED!

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

You failed to use a loop, as explained in this and this posts

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

don't understand what you are trying to say. Variables a, b, c and d do not appear in the code you posted.

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

windows.h will not work with turbo c++ because its too old of a compiler. There are other threads here about the same topic, suggest OP read them.

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

rand() is prototyped in stdlib.h

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

They wrote their own and that's what the DDK lets you do.

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

what is the step by step procedure to make your program run...
using c++

Depends on the compiler and operating system. Tell us what you want to use.

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

If you are going to do that then you don't need the BLINK attribute.

forever
   show text in color
   delay a few milliseconds
   erase text
   delay a few milliseconds
   generate another random color attribute
end of loop
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

In the program you posted you will have to define all the special keys to have different values -- you can't use those values because they conflict with normal keys.

Then just delete lines 37-49 because they are all wrong. You won't get any of those values on the first call to getch().

The if statement on line 51 also needs to check for value of 224 because thats what is returned when an arrow key is pressed.

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

getch() will return either 0 or 224 when you press special keys like F1-F10 and arrow keys. If it doesn't return one of those two values then you just pressed a normal key. After getting either 0 or 224 you have to call getch() again, then convert that value to something with will not duplicate normal keys. I've seen two different methods of conversion, either can be used as long as you use them consistently.

  1. make the keystroke value negative. Such as keystroke = -getch();
  2. Add 255 to the value such as keystroke = getch() + 255;

Run this little program and press several keys to find out how it works.

#include <stdio.h>
#include <conio.h>

int main()
{
    int keystroke;
    while(1)
    {
        keystroke = getch();
        printf("keystroks = %d\n", keystroke);
        if( keystroke == 0 || keystroke == 224)
             keystroke = getch() + 255;
        printf("keystroks = %d\n", keystroke);
    }
            
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If it is for MS-Windows then start with the Windows Driver Development Kit (DDK)

I have no idea how much time it might take one person to do that job.

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

Not usually, most libraries do not provide you with the source code so recompiling it will be impossible. In other cases when you get an open source library you will also get the source code. Check the download file to see if it already contains the binary DLL, if not then you will probably have to compile it.

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

did you bother to click that link or did you just read the suggested price?

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

The only way I can think of to change the color of the text on every blink is to write a clock interrupt function and change the color in that function. Clock ticks about once every millisecond, so your interrupt function will want to make the change only once every 1,000 ticks. Turbo C++ may have a compiler-specific function to help you with that, I don't know.

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

I don't get it. What is that +1 supposed to do (other than DaniWeb giving us activity points). Yes, I clicked it and some google box came up. But why??

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

:icon_question::icon_question::icon_question:

what did you mean:icon_question:

He was joking :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Sadun89 commented: Ohhh....Nize +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

many compilers do not support that construct -- the compilers will require num_grades to be a constant. g++ is one of the few compilers that recognize that construct, which is new to c++0x, which is not yet an official version of c++ standards. Use a different compiler and you will most likely get an error on that line.

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

Look under "Legacy and other languages". COBOL is one of those ancient languages that is not used very much any more outside financial institutions such as banks. You probably won't find much help for it here at DaniWeb. You might start learning COBOL by reading some of these tutorials.

What operating system are you planning to use for your COBOL programs? Here are some free COBOL compilers for MS-Windows.

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

Ok, here goes

#include <stdio.h>

int main(void)
{
	int num_grades;
	int *grades = NULL;
	int i;
	int j;

	printf("How many grades to sort?: ");
	scanf("%d", &num_grades);
        grades = malloc(num_grades * sizeof(int));
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 8. That declaration won't work because the value of num_grades is unknown when that line is executed. And it may not compile with most compilers because most compilers do not yet support the upcoming version of C standards. What you should do is declare it as a pointer then call malloc() to allocate the array after the value of num_grades is known (after line 13)

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

>>I'm not a native English speaker.

Good :) I don't know a second language, but if I tried to learn I would be horrible at it. I am never critical of people whose native tongue is something other than English.

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

Ok, so now I'm blind. My eyes completely missed those links.:sweat:

jingda commented: You need another pair of eyes:) +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Please tell me where to find the link

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

i also make a program to do hibernet the computer but these code are not working

can you tell me that how can i use system() function in c compiler

That can not be done from Turbo C. You have to use a modern 32 or 64 bit compiler such as Code::Blocks or VC++ 2010 Express to access MS-Windows programs. The best you can do from Turbo C is to run old MS-DOS commands.

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

Tutorials? Plenty of them in the hardware and software forum, see them everyday:)

Oh really??? Where are they then? The only links to code snippets any more are from within the member's profile. But I don't want to search 50,000+ member's profiles just to find tutorials and/or code snippets.

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

what compiler? Code::Blocks and vc++ 2010 Express are both free.

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

We will not do your homework for you, you need to first post what you have tried.

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
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

depends on the compiler. What compiler did you use to produce that assembly code?

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

>>what advantages there are from using a more up to date compiler?

1. Bug fixes -- yes gcc has had its share of bugs too

2. c and c++ standards change. And they will change again in the near future. You need an up-to-date compiler which complies with those new standards.

3. Better performance. Compiler writers are always attempting to make their compilers faster and make the code they generate faster. If you are writing commercial programs you will want to take advantage of that.

jingda commented: + +9