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

>> Is c++ useful?

Naw -- that's why there are millions of programs written in c++.

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

A couple solutions:

1. Delete general.h from Form1.h and just add function prototype for the function that's in general.h.

// Form1.h
 #pragma once
extern void ChangeFormText(); // <<<<<<<<<<<<<
namespace My666 {
	using namespace System;
	using namespace System::ComponentModel;

2. Put the implemnentation code for the function in general.h in general.cpp then only have the function prototype in general.h.

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

Just as I thought -- recursive includes. Form1.h includes general.h and vice versa.

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

I just tried it and had no compile errors. Do you have General.h included at the beginning of Form1.h? (recursive includes)

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

Text is probably declared private in Form1. In Form1 write a public get and put functions to expose Text to the public.

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

It's called Token Concantination. See this wiki article about preprocessor directives. Scroll down until you find the section titled "Token concatenation".

[Edit] Oops! Didn't see your answer Narue.

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

You could just turn off all those emails so that you don't get them any more. There are options in your profile to do that.

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

You are assuming the light from the UFOs are the same as we make them. If they are smart enough to travel between stars then surly they can make better lights then we can.

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

>>Is it the same for an inkjet?

An injet is in the class of a laser printer.

The easiest way to send files to the printer is with this free PrintFile utility.

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

Yes, I like the miniseries (its not a movie) V. Its just as likely to be as true as anything in Star Trek or any other sci fi flick.

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

Sending data to a laser printer is very complicated. You could use win32 api printer functions, such as EnumPrinters() and OpenPrinter().

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

UFO = Unidentified Flying Object -- it doesn't mean the UFO came from some other planet, all it means is that no one knows what it is. Most UFOs are eventually identified.

Now if you asked us if we believe there is intelligent life on other planets, my answer would be most definitely yes. We are not alone, but we may never be able to prove it one way or the other due to distances between stars.

Have I ever seen a UFO? Yes, but it eventually turned out to be a military hilicopter (I live near a military installation that has lots of aircraft).

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

I could, but I don't have time right now. Got to go to work now. Sorry.

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

call win32 api function EnumWindows(). For each window M$ will call your callback function with the handle of a window. In that callback function call GetWindowText(). Then all you have to do is strcmp() the returned text with that name. If its the window you want then send it a WM_CLOSE message with PostThreadMessage(). The first parameter to PostThreadMessage() is a handle to the process. You can get that by calling GetWindowThreadProcessID()

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

all graphics are out of reach of beginners (< 6 months studies). You better have a firm foundation in c and/or c++ before starting down that road.

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

There are os specific functions to get a list of file names in a folder.
MS-Windows: FindFirstFile() and FindNextFile()

*nix: opendir() and readdir()

google for those function nanes and you will find out how to use them. I've posted a couple code snippets here to show how to use them in c++ programs.

boost has portable functions to do the same thing, but I don't know the function names.

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

Your teacher is correct. You do not put executable code in header files (there are a few exceptions) because the code gets duplicated in each *.cpp file in which the header file is included. Lets say you have two *.cpp files, and each one of those includes the header file. The compiler won't complain when compiling those two *.cpp files, but the linker will produce duplicate declaration errors.

The simplest way to solve the problem is to put the implementation code in one of the *.cpp files, and put a function prototype in the header file.

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

instead of swap() use erase() e.g. my_map.erase(my_map.begin(),my_map.end()); Then you can delete lines 15-18 of the code snippet you posed.

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

Here's what I have so far. Obviously it loops through and just keeps looping so when I want to store values let's say seat one ordered a water for 0.00, seat two ordered a soda for 1.29 and seat 3 did as well. Then would I have to go through a separate loop for each of the other items such as meal, appetizer and dessert? I'm assuming I can use an If statement to allow the user to exit this loop and continue on to other portions of the program.

#include <iostream>
#include <cmath>
#include <string.h>
using namespace std;

int main () 
{
	int i, itemNumber = 0;

char names[5][25]; // an array of 5 names, each name can have up to 24 characters
int quantity[5];
strcpy(names[0],"Drink");
strcpy(names[1],"Appetizer");
strcpy(names[2],"Meal");
strcpy(names[3],"Dessert");

for(int i=0;i<25;i++)
{
int itemNumber = 0;
cout << "What do you want to order?";
cin >> names[itemNumber];
cout << "How many?";
cin >> quantity[itemNumber];
}




return 0;
}

1. itemNumber has to be declared outside the for loop so that it doesn't get reinitialized on each loop iteration.

2. The arrays you posted only has room for 5 items, so the loop needs to count from 0 to 5, not 25.

Those arrays will hold items for just one person. If you need to store items for more than one person, all at the same time, then you will need a 3 dimensional arrays

int maxPeople = 5;
int maxItems = 5;
int maxNameLength = 25; …
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

lets say you have two arrays

char names[5][25];
int quantity[5];

now you, the waiter at the restaurant, ask the guest wbat he wants to order

int itemNumber = 0;
cout << "What do you want to order?";
cin >> names[itemNumber];
cout << "How many?";
cin >> quantity[itemNumber];

Now put all the above in a loop and you have it.

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

you need to know arrays of strings as well as arrays of integers.

Here are a few examples of character arrays. You could also use std::string c++ class, but its doubtful you have learned anything about them yet. You will have to include string.h (or <cstring> ) in order to use strcpy() function shown below.

char name[25]; // an array of characters that hold a name of up to 24 characters

strcpy(name,"Hamburger"); 

char names[5][25]; // an array of 5 names, each namne can have up to 24 characters
strcpy(names[0],"Hamburger");
strcpy(names[1],"Pepsi");
strcpy(names[2],"Fries");
strcpy(names[3],"Milkshake");
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

For the record, deprecated means that something is in the C++ standard but not recommended because it might be removed in future revisions. iostream.h wasn't, and isn't, part of the standard at all.

You are right, but its still referred to as deprecated, for example here

The pre-ISO C++ headers (iostream.h, defalloc.h etc.) are available, unlike previous libstdc++ versions, but inclusion generates a warning that you are using deprecated headers.

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

When is your assignment due? You will need to know about input/output functions like cin and cout, as well as arrays and optionally structures. You will need some way to hold the name of the item ordered and quantity of each item. You can do that with either two arrays (one for name and the other for quantity), a structure, or c++ class.

Your program will also have to have some way to calculate total price of each guest's bill. To do that you will have to have another array of menu item names and their prices. You can do that with a structure that contains item name and price, or two arrays, one for names and the other for prices. Which one you choose will depend on if you know how to use structures or not. Structures are preferable because they let you keep related items (name and prices) together easier.

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

what compiler are you using? Many old c++ compilers use now-deprecated iostream.h

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

Your first suggestion is not workable because as previously explained the first letter can be one of several commands. But your second suggestion is the best way to write the program.

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

I'm interested in graphics programming. what library do I use for graphics programming in C if graphics.h is deprecated??

On MS-Windows use a modern compiler such as VC++ 2010 and win32 api graphics functions. c++ gives you many more options.

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

If you are just starting to learn assembly then those books for 32-bit systems will also work on 64-bit systems. Err -- I mean that it won't matter whether you use 32 or 64-bit computers. I first learned assembly during the late 1980s by reading a book by Peter Norton.

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

Whats in there?

Make a monetary donation to DaniWeb and you too will be able to enter Area 51.

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

^ Sick Narue on you for starting this stupid game.

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

when death is no longer a scary thought.

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

According to this the += operator is not supported. Can you provide a link that says otherwise?

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

post declaration of nameList. If it's std::string namelist then there will never be a NULL entry.

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

>>don't tell me windows doesn't speak posix

It doesn't. MinGW is a port and the underlying code that runs under MS-Windows just calls win32 api functions. Most win32 api functions do not support posix.

But I agree with you that you should use MinGW if the program is to be ported between the two operating systems.

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

Here are a few google links that can probably help you. If your computer is running MS-DOS Version 6.3 or earlier then TSRs should be ok. It's not likely they will run under either Vista or Windows 7 command prompts.

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

I just tried to compile that code on Ubantu and got the same errors. If you look at /usr/include/string.h you will see that strdup() is conditionally defined

#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
/* Duplicate S, returning an identical malloc'd string.  */
extern char *strdup (__const char *__s)
     __THROW __attribute_malloc__ __nonnull ((1));
#endif

As Walt already said strdup() is not an ansi function. You will have to remove the -ansi flag from the command line options in order to use strdup(), or define one of the macros in the #if statement.

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

opendir/closedir/readdir is in POSIX, so should work with your operating system.

He's using Windows 7, not *nix. Windows 7 doesn't support those functions.

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

Just copying the lib files into your project directory doesn't solve a thing. You have to add the lib names to the project settings. Its been a long time since I used that version of the compiler and don't recall how to do that.

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

Rotate the mouse on your desk through 180 degrees.

LOL :)

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

On MS-Windows use FindFirstFile() and FindNextFile(). Here is a more extensive c++ example.

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

I compiled it with VC++ 2010 Express and got no such warnings or errors. Are you sure you are compiling this as C program instead of C++. With vc++2010 *.cpp files are compiled as c++, not C. Change the file extension to *.c and recompile.

>>Vector is a C collection class .
Correction: its C++, not C.

[edit]Just tried to compile as c++ and didn't get the error then either. Of course I don't have the header file nrutil.h, so the problem might be a conflict in that file.

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

what do you mean by that??:S You need to explain your question in more detail

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

You wouldn't have any of those problems if you used VC++ 2010 (the Express edition is free). Code::Blocks is also an excellent IDE that has option to install MinGW compiler. I never used Eclipse so I don't know how to resolve your problems with it.


I assume you are working with some version of MS-Windows. Which one?

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

I was always heavly addicted to tobacco until I quit about 10 years ago. Quality of life has greatly improved since then.

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

Did you make the changes I said you needed to make? Your program ran ok for me without any Sleep() calls.

Do yourself a favor, save a lot of time, and get vc++ 2010 express so that you can easily debug your programs. You need to start coding in the 21st century.

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

Your program worked ok for me after making the changes I suggested.

>> I use borland 5.5 at the command line and i don't get them
Maybe you need to increase the warning levels issued by your compiler.

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

There are commercial grid controls that will let you do that, if you're willing to spend a few $$$. But you can also get a very good free one from here. I used that one for 5 or 6 years in some of my projects. Its over 10 years old now and has been tested by dozens of programmers in countless projects. And since you get the source code for free you can customize it to do anything you want, but customization is probably not necessary for your purpose.

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

There are several problems with the code you posted.

1. reg.h line 1. There is no such file as <windows> -- Microsoft never removed the extension for c++ programs.

2. reg.cpp, RegistryEntry::AllSubkeys. Variable BuffSize is used before it has been initialized. initialize it to sizeof(Buf)

3. Move the implementation code for GetValue() from reg.h to reg.cpp because it causes duplicate declarations in every *.cpp file that contains reg.h.

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

I got that stupid message too, so I disabled it. If you are running Norton 360, click that green tool on your desktip and it will bring up a Norton window. On that window select menu item Settings, then Antivirus link. From there you can turn off SONAR Protection.

With VC++ 2010 Express (which I also use) you have to put the file you want to open in the same folder as the program's *.cpp files.

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

If Norton were the cause then you would have gotton a Norton error message. If file.open() fails the only reason on MS-Windows is that the file is not in the directory you think it is. What compiler are you using?