|
If you're an MSDN subscriber then you can still download the old 16bit Visual C++ 1.52. It certainly can create DOS apps as we have the misfortune of using it for a product with an embedded DOS.
Matt
|
|
|
|
|
Xds wrote:
Specifically, it's missing things like textcolor() and gotoxy().
You can use the API.
For example, where you need gotoxy() you can use SetConsoleCursorPosition().And SetConsoleTextAttribute() instead of textcolor().
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
As mentioned, Turbo C++ is free now. Also, if you don't want to spring for MSDN you can buy the book "Learn Visual C++ Now" by Mark Andrews. It comes with a copy of VC++ 1.0 which still compiles DOS apps.
Jeremy L. Falcon
"You do not know the power of the dumb side."
<nobr>
Homepage : Sonork = 100.16311 Maybe my mangling might misguide malicious miscreants momentarily?
|
|
|
|
|
I am trying to set pixel colors by 'adding' colors based on the current background pixel. E.g., if the pixel falls on a white one, it should be displayed as a gray one, if it falls on a gray one, it should be black. I am using CDC::GetPixel() to retrieve the color into a COLORREF structure. How do I now extract the values for the R, G, and B components? Is there a better way than GetPixel?
Thanks,
Ralf.
ralf.riedel@usm.edu
|
|
|
|
|
COLORREF clr = RGB(123,60,55);
int r = clr & 0xFF;
int g = (clr & 0xFF00) >> 8;
int b = (clr & 0xFF0000) >> 16;
-Jack
To an optimist the glass is half full.
To a pessimist the glass is half empty.
To a programmer the glass is twice as big as it needs to be.
|
|
|
|
|
the GetRValue, GetBValue, GetGValue macros all work well.
-c
I don't care, and you can't make me.
|
|
|
|
|
Hah, Leave it to me to find the hard way to do it.
-Jack
To an optimist the glass is half full.
To a pessimist the glass is half empty.
To a programmer the glass is twice as big as it needs to be.
|
|
|
|
|
well, you're doing exactly what those macros do
-c
I don't care, and you can't make me.
|
|
|
|
|
Following is instructions for a small program that I have to write for school but I can't get mine to work properly. I would be forever grateful to someone if they could help me out. Here are the instructions:
5 individuals have bought lottery tickets in SCs new pick 6 lottery.
Have each person enter her name and her six numbers (the numbers
must be between 1 and 48, and there should be no duplicate values).
After all of the names and tickets are entered, populate (fill) a 6
element array with 6 randomly generated numbers (no duplicates!).
If a user picked 4 of the numbers correctly - she wins $1000.
If a user picked 5 of the actual numbers - she wins $10000.
If a user picked all 6 numbers correctly - she wins $1000000.
Note, the order of the numbers does not matter.
Print out the names of each winner and the amount of money
she won.
Your program must use AT LEAST two functions in addition to your
main (write more if you would like):
1. Write a function that takes an array and a size as its parameters.
This function should fill the array with random numbers between 1
and 48 - ensuring that there are no duplicates.
2. Write a linear search function.
Here is a suggested plan of attack:
1. Make your program read in one person's name and lottery picks
(into an character array with one row and 20 columns and a one
dimensional integer array with 6 columns).
2. Make sure that the user's numbers are in range and are not duplicates.
Do this as the numbers are being read in. - YOU CAN SKIP THIS
STEP AND COME BACK TO IT AT THE END IF YOU WANT
3. Write a function that takes an integer array as its parameter and
fills the array with 6 random numbers between 1 and 48.
4. Make sure the function written in step 3 is not allowed to place
duplicate values in the array. (You may want to reduce the number
of possible values to 1-6 in order to test that this feature is working)
- YOU CAN SKIP THIS STEP AND COME BACK TO IT AT THE
END IF YOU WANT
5. Print the elements in the array of randomly generated values.
6. Search the array of randomly generated values for each of the user's
numbers. Keep a count of the number of values found.
7. Construct a decision structure that will print the user's name and
winnings if she won.
8. Go back and make steps 1 and 2 read in 5 names and sets of
lottery picks.
9. Go back and make steps 6 and 7 check the picks for each of
the 5 people.
Donna
|
|
|
|
|
I'd follow the plan of attack outlined in your post. It seems pretty helpful.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I did follow the instructions, but my instructor told me that although my program looks like it works, my array is full of junk!
|
|
|
|
|
Donna wrote:
my array is full of junk!
Post some sample code ... we can't really help you... and I don't really
think we'll provide ( at least I ) you with a fully coded solution...
Max.
|
|
|
|
|
As you will see, I am extremely new at this but here is what I have so far:
#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
#include <time.h>
void lotteryNbr(int[], const int);
int linearSearch(int[], int, const int);
int main(){
char names [20];
const int sizeOfArray = 6;
int num[6],a[sizeOfArray],element;
cout <<"Please enter your first name " << endl;
cin >> names;
cout <<"Hi, "<< names << "!" <<" What numbers did you pick for";
cout <<" this weekends lottery drawing?" << endl;
cout <<"(6 integers between 1 and 48, no duplicates!)"<< endl;
for (int i = 0; i < 6; ++i){
cin >> num[i];
}
lotteryNbr(a,sizeOfArray);
element = linearSearch(a, num[i], sizeOfArray);
if (element != -1)
cout << "You have won the lottery!" << endl;
else
cout << "Sorry you didn't match any numbers." << endl;
return 0;
}
void lotteryNbr(int gameNbr[], const int arraySize)
{
cout << "This weeks lottery numbers are " << endl;
srand(time(0));
for (int j = 0; j < 6; ++j){
gameNbr[j]=(1 + rand() % 6);
cout << gameNbr[j]<< endl;
}
}
int linearSearch(int array[], int key, const int arrayLength)
{
for (int n = 0; n < arrayLength; ++n)
if (array[n] == key)
return n;
return -1;
}
|
|
|
|
|
I think you're missing a couple of includes ...
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <time.h>
using namespace std;
1- Should try to validate each user input so that it's between 1 to 48 ...
2- The random generator only generates numbers up to 6 ( get it, up to 6 that's
a hint )
3- To check whether you've win or lost, you need to check each number of array "a"
with each number of array "num", now, you are only checking the last number of
num ( which by chance works ) because "i" luckily "5" because of the loop;
this function should either do everything ( with the 2 arrays as parameters ),
or with one user number and the picked number array and return true/false to
say whether the user picked a good number, and in that case, will increment a
counter that will enable you to do the "decision structure' ( a big if statement
or a case statement ).
4- you're on the way ...
Good luck.
Max.
|
|
|
|
|
Damn, I can't put the include brackets ... that's why I didn't see yours...
Max.
|
|
|
|
|
You need to check 'display message as is' to stop the < > from being stripped as HTML tags. Or you can use & and lt or gt to get them, as I did here.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
You need to check 'Display this message as-s (no HTML)' below if you're going to have #includes in < and >.
Donna wrote:
gameNbr[j]=(1 + rand() % 6);
This line is going to generate numbers between 1 and 6. Is this what you want ? Also, I see no checking for duplicates.
I also don't get how your linear search works. I think you want to step through your numbers, and call linear search on each of them, and count how many you find. As it stands, I don't see how it could work.
I also don't see a using statement anywhere - you're not including iostream.h, are you ? You need to include iostream instead, which means you need a using statement for namespace std or, preferably, for each element you use, in this case only cin and cout.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Or you may use the code & # 0 6 0 for <, and & # 0 6 2 for >.
that's a bit like ASCII code...
Maxwell Chen
No code is good code.
|
|
|
|
|
My header files did not print to the screen like I had them in my program! The greater than and less than signs and what's in between them does not show up on the message board! The header files were iostream.h, iomanip.h, stlib.h, and time.h.
|
|
|
|
|
I explained to you why that is above, and also explained why including iostream.h, iomanip.h, etc. is plain wrong.
I don't use C functions, because I prefer C++, but I believe that stdlib.h and time.h are also deprecated, in favour of cstdlib.h and ctime.h.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Do you know the escape sequence in C/C++. For example: \0, \n, \a, \r, \t, \\, or %%, etc. ??
HTML has such thing, too! Now follow my step-by-step...
1) Open(create) a new file with the notepad.exe.
2) Type such things
&*#*0*6*0*S*T*D*I*O*.*H*&*#*0*6*2*
3) Save this document in a name, like "WebDoc.txt". Do not close this document.
4) Use the replace tool (Ctrl+H), replace all the * with nothing (Not ask you to put a lot this word 'nothing's, just delete all * symbols.)
5) Save this document again, close it, and rename it as WebDoc.htm.
6) You see the icon of the file becomes a web document.
7) Open this document with your browser (IE or some other one...).
8) You now see this:
<STDIO.H>
Maxwell Chen
People say "No news is good news". Then, no code is good code!?
|
|
|
|
|
Hi,
I have a DDE server running on a Windows 98 plattform.
A DDE client , executed by IIS (internet Information Server), communictes with it and everything is OK. Both, client and server uses ddeml. When I try to do the same on WinNT or Windows 2000 I have the following problem: the DDE client , executed by IIS, attempts to communicate with the DDE server but, the server never receives the message. But, when I run the DDE client from the shell (on NT or 2000), again, everything is right. The client sends the message and the server receives it. The DDEspy reports DDE activities when the client is executed from shell, but when it is called for the IIS, DDEspy doesnt report DDE activity.
Could anybody help me?
Valeria león
|
|
|
|
|
Probably a security problem. The client and the server are probably running on different desktops and thus don't see each other.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Hi,
Both applications: DDE client and DDE server are running in https/cgi-win. If they are in different desktops, how can I solve this? On Windows 2000, my system file is FAT.
TANK YOU.
Valeria León
|
|
|
|
|
I have created this dialog based application consisting of several pages (property pages) and I would like to load a bitmap that I created. I want this bitmap to be displayed on the 1st page.
thank you very much! = )
|
|
|
|
|