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

I got that same output with the code you posted.

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

Oh yes I see it now -- I had to press Tab to get to the screen with the grid. After clicking several times it finally failed.

I think I found it. Its writing beyojnd the bounds of arrays. You are allocating too few POINT3D structures.

void DrawMap(HDC hDC, int ScaleWidth, int ScaleHeight, int XOff, int YOff)
{
	POINT nullPT;

	if(plgonsize >= 3)
		{
		p3d = new POINT3D[plgonsize];// - 1];
		new_plgon = new POINT[plgonsize];// -1];

		for(int p = 0; p < plgonsize; p++)
		{
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't see a grid on the screen, and clicking on the screen does nothing.

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

funny that the code works ok for me. Are you certain we have the same code ?

memory leak here -- you need to delete the pen after creating it.

case 0://DRAW PERSPECTIVE
			DrawMap(hDC, ps.rcPaint.right, ps.rcPaint.bottom, ps.rcPaint.right / 2, ps.rcPaint.bottom / 2);
			hPen = CreatePen(PS_SOLID,5,RGB(255, 0, 0));
			SelectObject(hDC, hPen);
			TextOut(hDC, 0, 15, "[A: move left] [D: move right] [W: move forward] [S: move backward]", 67);
			TextOut(hDC, 0, 30, "[UP: move up] [DOWN: move down]", 31);
			break;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

more than likely yes, but I'd have to see the code for a difinitive answer. What os are you using because Dev-C++ has worked for me on every recent version including Vista.

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

maybe yes, and maybe no. Depends on the code and what compiler it was written with. If written with Turbo C then probably won't work with VC++.

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

If you wrote that then you should know why. You should also reformat the code to make it easier to read and understand. Example below:

#include <iostream>
#include <string>
using namespace std;
int main()
{
    string softserve, topping, sprinkles;
    string order;
    do
    {
         if (softserve == "")
              cout << "Do you want chocolate, vanilla or twist?\n";  // endl not needed here
        if (topping == "")
<snip>
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Your program seems to be too complex.

int main()
{
  FILE *pS, *pD, *pT;
  int a, n=0;
  int[/color  c=0;
  char *dabuff;

  pS = fopen("INVITACION.TXT","rb");
  pD = fopen("BACKWARDS.TXT","wt");
//
// no need to use sizeof(char) because its guarenteed to be 1 by the standards
//
  fseek(pS,-1,SEEK_END);
  while( ftell(pS) > 0)
  {
     c = fgetc(pS);
     if( c != '\r' ) // you don't need this for *nix or MAC
         fputc(c,pD);
     fseek(pS,-2,SEEK_CUR); 
  }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

By tradition the two arguments to main() are declared as argc and argv -- you can name them anything you wish but custom dictates those two names int main(int argc, char* argv[]) how do you know your program returns 1? The code you posted returns 0, not 1 (see the return statement).

>> thought it would return the value of x
why? x is not the return value (last line of the program). [edit]Yes, I realize this is not really what you meant, but when writing programs you have to be very specific about questions to avoid ambiguity and confusion [/edit]

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

Its not necessary to initialize std::strings with blanks because that is the default. Just declare them like this: std::string softserve, topping, sprinkles; I think your program needs more cin statements for data entry.

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

You can do it any way you want. You don't even have to nest the two functions like I showed you.

int n = function2(number.one, number.two);
cout << function1( n, number.two);

There are lots of ways to do what you described. Let your imagenation be your guide and try them out with your compiler to see what happens. Practice makes perfect :)

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

First, open the file in binary mode so that the os doesn't interpret the '\n' characters. Then you have to call seek() after each read operation.

What you do with '\n' depends on what operating system you are using. *nix files just have '\n', but MS-Windolws uses '\r' and '\n', and MAC uses just '\r'.

int chr;
ifstream in("filename", ios::binary);
in.seekp(-1, ios::end); // see one byte from the end
do  {
    chr = in.get();
    in.seekp(-2, ios::cur);
} while( in.tellg() > 0); // while not at beginning of file
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

After making the above changes the dot still doesn't move because you neved added code to move it.

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

I uncommented the code but didn't crash and didn't actually do anything, meaning the dot didn't move when I pressed any of the keys. Probably because the case statements are wrong, for example the letter 'A' is 65, not 61. You need to look at any ascii chart. you might also want to accept either 'A' or 'a'. And the easiest way to do it is like this:

case WM_CHAR:
            switch (wParam)
            {
                case 'A': //a
                case 'a':
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

To change UNICODE setting: Select menu Project --> Properties (at the bottom of the menu), expand Configuration Properties, select General, then in the right-hand pane change Character Set to Not Set

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

or this using FILE*

char iobuf[255] = {0};
while( fgets(iobuf, sizeof(iobuf), pS) )
{
     fprintf(iobuf);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is one way it could be done.

class example
{
public:
   int one;
   int two;
};

int function1(int one, int two)
{
   return one * two;
}

int function2(int one, int two)
{
    return one + two;
}

int main()
{
    example number;

    cout<<"enter numbers"<<endl;
    cin>>number.one>>number.two;   
    cout << function1( function2(number.one, number.two), 3);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'm running on 64-bit Vista Home Premium, used VC++ 2008 Express, and your program ran ok for me both in IDE and command-line. After creating a win32 windows project I used all default values except changed from UNICODE to non-UNICODE.

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

The morale of the story -- always make backups of inportant files. Your computer has floppy and CD RW drives for a purpose -- use them.

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

I read somewhere that someone would pay for me putting their links in my signature (not necessarily ME but anyone). Is that just a scam to get people to post their links ?

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

you can ask ten programmers to write the same program to the same specification and get ten completely different solutions.

But only one correct solution -- mine :)

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

line 61 (as shown in your post). You can not copy a character array into an int array. I guess same problem with the other lines that follow that one.

line 60: >>if(factory_info[a].machine < factory_info.machine)
You can't compare two C character arrays like that -- use strcmp() instead if( strcmp( factory_info[a].machine, factory_info[b].machine) < 0) After that, all you have to do is copy the entire structure -- not necessary to copy each field

if( strcmp( factory_info[a].machine, factory_info[b].machine) < 0)
{
    factory temp;
    temp = factory_info[a];
    factory_info[a] = factory_info[b];
    factory_info[b] = temp; 
}

You can also use memcpy() to copy those structures.

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

And they never hit anything anyway!

Not only that, but their guns never ran out of bullets :)

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

use fmod() function for doubles. Also do division with doubles, not integers or you will have problems with that too.

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

Your program works fine for me.

Sci: His last post was only main() -- the rest is in the origianl post.

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

The mod operator doesn't work on doubles -- only integers. And why is mph a double? Your program isn't even using the fractional parts so you might as well make it an integer and that will solve the problem for you.

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

1) after line 19

2) Change line 28 to test for return value of line 26

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

I guess you mean you want to know about the best compiler. On Vista that would be Visual C++ 2000 (Express). There are other compilers but IMO M$ VC++ 2008 Express is the best, mainly due to its excellent debugging facilities. Most any modern c++ compiler will compile c++ code ok, but trying to fix your mistakes can be very frustrating on most compilers.

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

line 20 is in the wrong place -- move it down to line 25, when the variable search_item is known.\

[edit]^^^ he beat me to it :) [/edit]

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

Is this code supposed to mean something?

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

I knew there was something fake about that woman. She's an actress, not a politician.

On Palin from a fellow Alaskan.
Like many Alaskans, I resent Palin’s claims that she speaks for all of us, and cringe when she tosses off her stump speech line, “Well, up in Alaska, we….” Not only did I not vote for her, she represents the antithesis of the Alaska I love. As mayor, she helped shape Wasilla into the chaotic, poorly planned strip mall that it is; as governor, she’s promoted that same headlong drive toward development and despoilment on a grand scale, while paying lip service to her love of the place.

As for that frontierswoman shtick, take another look at that hairpiece-augmented beehive and those stiletto heels. Coming from a college-educated family, living in a half-million-dollar view home, basking in a net worth of $1.25 million, and having owned 40-some registered motorized vehicles in the past two decades (including 17 snowmobiles and a plane) hardly qualifies Palin and her clan as the quintessential Joe Six-Pack family unit — though the adulation from that quarter shows the Palins must be fulfilling some sort of role-model fantasy.

Palin can claim to know Alaska; the fact is, she’s seen only a minuscule fraction of it — and that doesn’t include Little Diomede Island, the one place in Alaska where you actually can see Russia. So she can ride an ATV and shoot guns. Set her down in the bush on her own and …

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

To find your posts and threads: Click on your name in the Welcome line at the very top of the page. There you will find links to the posts to you have made and to the threads you have started. Also, in the list of threads for each board the threads you have contributed to are shown by a picture of a pencil in the far left-hand column.

To find my public profile just click on my avatar (picture).

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

I agree, this great country needs soldiers.

Its better to teach children the RIGHT way to handle guns then let them find out for themselves by shooting someone.

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

start by using google like this (see the search bar at that link)

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

The error on line 23 says variable i has not been declared. The reason is that you have to use { and } braces in the loop starting at line 19.

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

Your problem is that you didn't put anything at the end of main() to keep it from closing. Add getchar() just before the return statement.

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

Many programmers don't like putting return statements in the middle of functions. So here's another way to do it

int main()
{
   char answer;
    cout << "Do you feel sexy today?";
    cin >> answer;
    if( answer == 'Y')
    {
                // now do other things

    }
    return 0; // end of function
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

First call GetWindowLongPtr to get a pointer to its defaultProc then call CallWindowProc() when appropriate. See the GWLP_WNDPROC option.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
int main()
{
   char answer;
    cout << "Do you feel sexy today?";
    cin >> answer;
    if( answer != 'Y')
       return 0; // exit program
    // now do other things

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

Welcome to DaniWeb.


>>I believe I must be the oldest member here!
Not likely. See my public profile. And I know of at least one other member who is older than I am. So don't hesitate to post newbe type questions -- I still do that too.

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

Welcome to DaniWeb. And yes, its about time you get off your a** and introduce yourself to us :)

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

why would a c++ course ask you to write poetry?

>>I wonder if I can disscuss in this forum the way we think
You are free to discuss almost anything you want here in Geek's Lounge. But maybe a forum dedicated to writing poetry would be more appropriate place for you to discuss such topics.

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

requires too much thinking for me :)

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

Poetry is not normally spoken here.

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

My test reveals that I disagree with Obama on 63% of the questions, but I will vote for him anyway because there is no other choice -- McCain is just too old and I like his politics even less than I do Obama's.

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

They cant tell whats OK and what isnt most of the time and if they start playing with a TOY GUN,they might think a real gun is the same!!

Only when their parents fail to teach them the difference and fail to protect their weapons by putting them in a safe place where the children can't get to them. The only stories I've heard where children shot someone with a real gun is where the adult left the weapon lying around where the child could easily pick it up to play with. And those kids were all under the age of 10.

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

I don't have a problem with it. We played cowboys & indians when I was little, and I never really shot anyone with a real gun. On the otherhand, children often try to imitate what they see on TV, and TV today has a lot more violence than it did when I was growing up watch Roy Rogers and The Lone Ranger riding their horses after the bad guys.

So for today's youngsters maybe it is a bad idea for them to play with toy guns.

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

I dont want to cout the char I want pointer[a] to be the char.

Then declare pointer to be an array of characters, not an array of integers.

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

you can't insert strings into int arrays, but you can insert a character pointer[a][b] = '*'; <<< single quotes, not double quotes

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

dhingra initialize i and j in the previous comment statement ;)

Oh, so the code he posted is not the same as the code that is giving the problem(s).