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

>>I think I should start over
No, you should read the suggestions people have already given you and fix the problems. Then post your most recent code because I can't see your monitor from my chair :)

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

First, you need to make variable pass one byte larger so that is can contain the normall c string null terminator. Then lines 7-13 can be simplified like this

char pass[] = "pasqwe";

Notice you don't have to specify the size of the array when initializing it with a string like I did above. The compiler will figure that out itself.

Now in line 18 you probably should use a different variable so that it can be compared to the original. Line 22 can use strcmp() function to compare the two strings instead of comparing them one character at a time. Here, variable new_password is another variable I mentioned previously that is entered on line 18.

while( strcmp(new_password, pass) != 0);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Then.. How would I do a sort in a parallel array?
You are headed in the right direction, just need to learn how to access each element of the array. Array elements are numberd from 0 to the size of the array, in your program the array score has three elements numbered 0, 1 and 2. So if you want someone to enter the three values from the keyboard then use a loop that counts from 0 to 3, like this:

for(int i = 0; i < 3; i++)
{
    // display the prompt
    cout << "Enter score for " << names[i] << "\n";
    // get one score from the keyboard
    cin >> score[i];
    // now flush the keyboard of the <Enter> key that the user entered after the number
    cin.ignore();
}

Delete lines 23 and 24 of your post because they are unnecessary and do nothing at all.

And your sort algorithm needs some improvement. The j loop should start at (i+1), not from 0 because it does not need to check the values from 0 to i -- they are already sorted.

for(int i = 0; i < 2; i++)
{ 
    for(j = i+1; j < 3; j++)
    {

         // check and swap if needed
    }
}

Finally, its always more efficient to declare a const int at the beginning of the program that contains the size of arrays then use that throughout the rest of the program. That way if you want to …

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

you will have to allocate the array using the new operator, something like this:

int* scores = 0; // an unallocated array
int nItems = 0; // number of items user will enter to set size of array

cout << "enter array size";
cin >> nItems;

// now allocate the array size
scores = new int[nItems];
//
//
// delete the array before finishing the function
delete[] scores;

what is lines 18-42 supposed to do in your original post? It certinly is not sorting anything, and is referencing elements in the array that do not exist, such as at line 28.

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

Maybe he just is a bad lawyer? It's been my experience that people get jobs outside of their degrees either because they fell in love with an industry too late (i.e. after school) or because they aren't good enough to make it in what they have a degree in.

Could also be some people just get bored with their profession and want a change (burnout).

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

If the sex laws of the Bible (especially the adultery, promiscuity, and homosexual ones) had been obeyed by everyone, AIDS would not have ever infected more than a few people, and the epidemic would have been over by now.

And if the rabbit had not stopped to take a crap he would have caught that damed turtle too. People lived in promiscurity for over 4,000 years and didn't get aids until the last 50 years. So I doubt what you claimed is very relevant.

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

you are using integers, so the program drops all fractions. percentFigure / 100 is 0 for all values of percentFigure less than 100. Change data types to float and it will work as you expected.

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

I used Dev-C++, created a Windows program then added that macro and it compiled without a problem. Just had to include commctrl.h header file.

#include <windows.h>
#include <commctrl.h>
<snip>

ListView_InsertGroup(0,0,0);
<snip>
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>so considering the fact, that each line in the inFile contains all leters of the alphabeth, at some point or the other....i'd have to use a lot of if-else statements? For example... if (x>y)...all the way down?

Naw -- it is not that hard. What jamthwee posted was just an example to show you how to compare two strings. Since you have them in an array you can use a loop to run through them exactly like you would sort an array of integers. Like this bubble sort algorithm -- there are other more efficient sort algorithms, but this is ok for small arrays.

string names[25];
for(int i = 0; i < 24; i++)
{
   for(int j = i+1; j < 25; j++)
   {
       if( names[i] > names[j])
       {
            string temp = names[i];
            names[i] = names[j];
            names[j] = temp;
        }
   }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you have the source code then why can't you edit it? Should be simple plain-old text files just like the soruce for any other program.

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

try defining this at the top of your program. The macro compiles ok with VC++ 2005 Express but may not with other compilers. It only works on XP and Vista.

#define _WIN32_WINNT  0x501
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

where did you declare and code ListView_InsertGroup() ? It is not in any win32 api function that I know of so it has to be in your code someplace.

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

There are lots of things that could cause that behavior. I understand why you use that compiler. Post the code and maybe someone can help figure out the problem.

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

>>it gave me runtime error everytime I compi
Impossible. Compiling a program can not produce runtime errors-- such errors are called compile time errors. Only running the executable program can product runtime errors.

If that compiler gives you so much grief why use it? Toss it into the bit bucket and get a different free IDE, such as Microsoft VC++ 2005 Express or Dev-C++.

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

It is also quite possible that Ancient Dragon edited so it has lost its original meaning.

Nope. I didn't change the actual content of the post, just added code tags around that triangle to retain the spacing.

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

html files are just plain text files that contain html markup code. You can certainly do that with a c++ program. You can also create the document file providing you use Microsoft's Office Automation libraries or possibly the OpenOffice that was previously mentioned.

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

you can't. files know nothing about colors and fonts. The best you can do is use some sort of color tags that is recognized by the program that reads the file -- for example Notepad doesn't recognize any, but the browser might if you use color html tags.

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

moved

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

You can use curses library to get standard format (I think). It's been many years since I programmed for *nix so I probably won't be much more help.

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

i need help

counjure up a 4-year-old thread then post some irrelevant crap -- yes you do need help.

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

Ok now I see what he did. I like it too :)

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

Huh ? Sorry, I don't get it.

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

Came across this when researching the answer to another question on c++ board and had to share. Just a couple of them below

May all your teeth fall out except for the one with the toothache!

May your daughter's hair grow thick and abundant, all over her face!

May DaniWeb deny you access forevermore!

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

Instead of attempting to change the size of the terminal (not sure that is even possible) figure out how to align the data correctly. That will probably require knowledge of and use of terminfo information because every terminal may be different.

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

Do you understand how function overloading works? If you do then think of operator overloading in the same way. They work because of the different parameters (if they have the same number of parameters then the parameter types must be different). The c++ compiler mangles function names by including the parameters are part of the function name, which is why you can have a c++ class with two or more functions with the same name but different parameters. Exactly how function names are mangled is compiler dependent -- compilers can do it however they wish.

I think the easiest way to get all that strait is to write a small test program, similar to what I posted above, compile for debug, then use the debugger to step through the code one line at a time so that you can see the execution flow.

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

There's not that much of a difference -- one is a member of a c++ class and the other isn't.

#include <iostream>
using namespace std;

class MyClass
{
public:
    void operator<<(std::string str) { cout << str;}
    std::string SayHello() {return "Hello\n";}
};

// non-member operator
ostream& operator<<(ostream& stream, class MyClass& obj)
{
    stream << obj.SayHello();
    return stream;
}

int main()
{
    MyClass obj;
    // invoke member operator
    obj << "Hello\n";
    // invoke non-member operator
    cout << obj;
    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is a simple example I found, hope it helps

[edit]I attached a zip file that I compiled with VC++ 6.0 [/edit]

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

a vector is a c++ array class, so just use a loop to access each Pizza object

int n = theOrders.size(); // get number of elements in the array
for(int i = 0; i < n; i++)
{
   outOrder(theOrders[i]);
}

You will want to add a parameter to outOrder function, similar to the parameter to addPizza().

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

This is an interesting thread that talks about command-line compiles

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

Er... the OP perhaps? just a hunch.

Ok, I get it now, your post was so far down the line that it was difficult to know. Most people today in the western world get AIDS out of their own stupidity, not because something awful just happened to them. I don't have a whole lot of sympathy for them. There are, of course, exceptions, such as children and spouses to catch it from unfaithful spouse.

jbennet commented: agreed +19
ndeniche commented: very right +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>e.g it costs 90% to buy after 2 years, 80% to buy after 3 years etc...
you mean the code will wear out ? :)

why not charge 200% or 300% of actual cost?

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

UNICODE is the default setting for that compiler so if you didn't turn it off then the compiler is mapping TCHAR into wchar_t. go to Project --> Properties (bottom menu item) --> Configuration Properties --> General then change Character Set option to Not Set. If you really do want UNICODE then you have to use one of the conversion functions to convert wchar_t* to char*

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

Thats not a very nice joke mate!!

How did you direct that to ? I didn't think anyone was making a joke of people with AIDS.

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

If Order can contain one or many pizzas then it should have a vector of pizza objects, and pass the Pizza object by referenct so prevent unnecessary duplication of the object.

class Order
{
public:
    void addPizza ( Pizza& order) ;
    void outOrder ( ) ;
private:
    vector<Pizza> theOrders;
} ;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

strstr() expects the first parameter to be a char* pointer, not a std::string object. use the c_str() method to get the pointer

strPtr = strstr(phone_book[index].c_str(), lookup);

But you don't need to use strstr() at all because std::string has a lookup function called find(). It returns an int to the beginning of the string or string::npos if not found

std::size_t pos = phone_book[index].find(lookup);
if( pos != string::npos)
{
   // found it
}

I wrote the above from memory so I hope its corect. If not the someone else will correct it.

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

The only thing I know about Holland is that they have lots of tulips and hills.

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

Physical location?

physical location of what :?: :?:

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

>>or, is the standard totally rigid - to the level of a mandate for the code in each function rather than a specification for each function?
The standards dictate the specifications, what the function is supposed to do. I'm not about to pay $289.00 USD for a copy of the standards so I can not verify exactly what it says or does not say about that function.

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

At what point (location and time) did the epidemic start? It is my understanding that Ethiopia, at least, has had (until relatively recently) a long-standing Judeo-Christian history.


And are you referring to the American definition of AIDS, or the African definition? The two are not the same, from what I've seen.

I didn't know there was different definitions. Raised in the 1940s and 1950s my vision of Africa is from the old Tarzan tv shows and movies -- a bunch of uneducated (by our standards), superstituous, black people running around with spears and near naked bodies.

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

>> it might work on my machine, but not work elsewhere
The behavior has nothing to do with what machine the compiled program is run on. Since strtod() is in C89 standards the function will behave the same on every modern C compiler.

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

ADOCE is a VB DLL that might can be used with C/C++ programs. It will probably work for you if you only have small amount of data. Alo read this and this

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

hi dragon;

thanks for your time. you did mention above about the a program to send SQL request to server. what do you mean by program, i have do it myself or can download somewhere?

I mean a DLL or a static library which contains functions that can be called by the application program. And you will have to write these yourself because those that I am aware of are proprietary and can not be released.

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

where is what wrong? Do you get compile errors ? If yes, then post some of them. Sorry, but I don't have my crystle ball with me today :)

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

If the first sequence of non-whitespace characters in str does not form a valid floating-point number as just defined, or if no such sequence exists because either str is empty or contains only whitespace characters, no conversion is performed

http://www.cplusplus.com/reference/clibrary/cstdlib/strtod.html

From the above I don't think the value of the third parameter to strtod() is changed. But the easiest way to find out is to write a small test program and try it out.

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

>>a sample program of c++ that uses a database
There are several alternative ways to do it, all somewhat complex and require a confortable knowledge of C or C++ language.. The most common approach is ODBC, and you can find a few free c++ ODBC classes -- just do a google search for them.

MS-DOS 16-bit programs can not access 32-bit MS-Windows databases. Any speed you will gain by printing with MS-DOS will be lost by attempting to transfer data between MS-Windows and MS-DOS.

>>I learned that it is more fast in printing in DOS mode program that to windows base
depends on what you want to print. If you want nice looking reports with different fonts and possible different colors then you have to use MS-Windows.

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

Are you using MFC or pure win32 api? My best suggestion for you is to download the several example programs you can find with google and try them out. Nothing helps one understand a problem like practicle demonstration.

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

since you have the names in an array and the scores in another array you can use a loop to do that, and add the code at about line 15 in your original program.

for(int i = 0; i < 3; i++)
{
    cout << names[i] << " Score: ";
    cin >> score[i];
    cin.ignore(); // ignore '\n' left in the keyboard buffer
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

if you write your own thing you will need to write two programs:
1. On the database server computer you need a service program (assuming MS-Windows operating system) that receives requests from the wireless device(s), send the requests to the database program, gather the result set(s) and forward the result set(s) back to the wireless devices. You can also write this as a deamon on a *nix box. And the database may reside on the same computer or another remote computer.

2. On the wireless device you need a program that sends sql requests to the server mentioned above and wait for the result. After receiving the result set(s) store the result sets in a format that can be used by the program running on the wireless device. The program I wrote stored the data in files so that they could be used later by any of several programs running on the wireless device. Sort of like writing your own database program. WinCE has its own built-in database manager but its just too slow to be useful for anything larger than some trivel requirements.

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

>>Different spaces moving in different directions and at different relative speeds to each other DO experience different times.
That is such a definite statement that I'd like to see the proof. When I drive down the highway is the car ahead of me in a different time than I am? I doubt it, but there is no way that I know of to prove it one way or the other. Same with your statement above.

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

The sex laws of the Old Testament were designed to prevent STDs. If everyone had been obeying them, there would never have BEEN an AIDS epidemic.

That might be true only if everyone in the whold wide world new about those sex laws. Since AIDS began in Africa its highly likely those people never heard of them. And from what I understand (maybe wrongly) AIDS started in monkeys, not humans. And I am certain those monkeys never knew about those laws either.