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

line 6: if you can enter 1-10 characters then that array isn't big enough -- need to make it size of 11 to hold the string null terminating character.

line 9: does your assignment require you to use dynamic memory allocation? If not, why are you using pointers ?

line 16: delete that line and allocate all the memory at one time on line 9 like this: char* Arr = new char[11];

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

Impossible to answer that question. There are probably billions of Fortran programs and each one would be a unique port. In many cases porting may not even be possible depending on the mathametical complexities of the fortran program. VB does not have the efficient mathametical functions that are available to Fortran, so a port may run considerably slower in VB.

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

>>is that possible?
Yes -- you must create additional thread(s) for the loops. There have been lots of threads here at DaniWeb and all over the net about that topic. Seek and thou shalt find :)

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

>>can any1 here please write a code for me please????
Yes -- deposite $100,000.00 in my paypal account and I will do it for you.

But someone else already did this assignment for you. Just read your other thread.

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

I know that you are joking but I am going to respond as if you weren't for those who don't see the joke.

"War boosts our economy" is an example of the 'Broken Window Fallacy' - imagine, if you will, 'a vandal throwing a brick through a shopkeeper's window. The shopkeeper will have to purchase a new window from a glass shop for a sum of money, say $250. A crowd of people who see the broken window decide that the broken window may have positive benefits:
After all, if windows were never broken, what would happen to the glass business? Then, of course, the thing is endless. The glazier will have $250 more to spend with other merchants, and these in turn will have $250 to spend with still other merchants, and so ad infinitum. The smashed window will go on providing money and employment in ever-widening circles. The logical conclusion from all this would be ... that the little hoodlum who threw the brick, far from being a public menace, was a public benefactor. (p. 23 - Hazlitt)The Broken Window Fallacy is enduring because of the difficulty of seeing what the shopkeeper would have done. We can see the gain that goes to the glass shop. We can see the new pane of glass in the front of the store. However, we cannot see what the shopkeeper would have done with the money if he had been allowed to keep it, precisely because he wasn't allowed to …

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

Thanks Dani. There was a few minutes I couldn't get to DaniWeb at all. But all seems to be ok now.

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

Post your questions and someone will try to help you. Several of the regulars here are fluent in assembly and other languages.

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

>>I think this will be possible in the next version of C++
You can do that now

struct CandyBar 
{
public:
    CandyBar (const char* brnd, float wt, int calors)
            : brand(brnd), weight(wt), calories(calors)
    {
    }
     string brand;
     float weight;
     int calories;
};

int main()
{
    CandyBar Bars("Violent Crumple", 20.5, 7000);
}

Apparently you can't make Bars and array, such as Bars[3] and use initialization lists like the above. Tried it but the compiler didn't like it.

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

want to count upper case 'A' and lower case 'a' separately or as a single character?

I would create an int array of 256 to represent all the possible characters in a text file. Actually that's more than is possible in a text file, but it makes the math easier. Then as you read each character you can let the character itself index into that array. For example, if the program reads the letter 'A'

int arry[256] = {0}; // declare the array

<snip>
int c;
// read a single character
infile.get(c);
// increment the counter for that character
arry[c]++;

Put the above in a loop, when the reading is all done you have the sum for each letter. Just loop through that array and print the values that are greater than 0

for(int i = 0; i < 256; i++)
{
    if( arry[i] > 0)
        cout << "Letter " << (char)i << " = " << arry[i] << "\n";
 }

You could also probably do this with <map> but the coding would be a little more difficult.

coolbreeze commented: definately a guru +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>WHY???

because you failed to correct this line as Salem suggested: scanf( "%d",year); Make that right then retest.

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

I was thinking the same thing as vmanes when I watched that. All fluff and zero substance. Totally useless in business except maybe for flashy presentations.

When is someone going to develop a hollagram monitor ? They've been around in sci fi movies for many years.

vmanes commented: Yes, let's go build one! +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This is the second time in about the last 5 minutes I have seen this

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

How about at the summer olympics ? Looks like Pepsi had a winner there :)

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

So what is the problem with that? What is the query you used to get the resultset ? Did your query ask for a column named contact ?

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

>>10. Always wear a belt
I wouldn't think of walking out of my house without one because my pants would fall to the ground and I'd have to flash everyone -- then I'd get tossed in jail for indecent exposure.

>>9. White socks are only worn during athletic activities
I always wear white socks because nylon socks cut into my ankles

>>8. Make sure nails are trimmed and clean
Yup -- I'm sometimes a little lax about the length and my nails split

>>7. No facial hair
None here -- but I thought women went for men with beards or unshaven. Apparently not.

>>6. Pants - no pleats or tapered legs
No problems there either.

>>5. If it has a hole, tear or discoloration throw it out
Young men (and their parents) pay good money at Wal-Mart for dirty pants with rips in them. They're called designer jeans

>>4. Running shoes are for the gym ONLY
I wear them 24/7 (except when in bed asleep of course)

>>3. Do NOT wear free or company t-shirts
I don't.

>>2. Do NOT tuck in your shirt (unless at a formal event or when layering)
Only tuck in button-down shirts. Otherwise leave them outside the belt. This has the additional advantage of hiding the buldging stomach.

>>1. Never wear socks with sandals
Never wear sandals.

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

Ok you guys screwed up I guess because of all the respoinses in this thread I can't delete it as spam.

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

>>if(ch = 48,49,50,51,52,53,54,55,56,57)
You can't construct an if statement like that if(ch >= 48 && ch <= 57) or better yet if( ch >= '0' && ch <= '9')

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

Q1: put the strings in an array and then sort them.

#include <vector>
#include <string>
#include <algorithm>

<snip>

std::vector<std::string> strarray[3];
<snip>
std::sort(strarray.begin(), strarray.end());

Q2: Open and close brackets are incorrect.

if (ch = 32)
{
    cout << space << endl;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Any other ideas why?

Most likely crased because you didn't change "%.3lf" to "%d" everyplace. If you did that then you have to post the code again

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

c++ has bool data type, so use it instead of that unsigned int

class Cat
    {
          public:
                  
          unsigned int Age;
          unsigned int Weight;
          unsigned int Siblings;
          bool Smoke;
          bool TV;
          
          void Meow();
    };

<snip>
    Elliot.Smoke    = false;
    Elliot.TV       = true;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Thanks smartass...
Yes -- this is the Greek's LOUNGE afterall where silly answers should always be expected. If you want serious answers then post in one of the technical or software forums.

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

Those Read Me threads are NOT advertisements or spam. We try to keep as much spam and other crap out of DaniWeb as quickly as possible.

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

c-style casting only hides the problem just like tye static_cast I attempted to use earlier. The dynamic_cast illustrated here works as it should because its not trying to cast up the chain. Microsoft Foundation Class (MFC) uses a pretty slick way to get around this, but I don't know its internal workings.

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

To assure that the base class is pointing to the correct child class we use 'dynamic_cast' . This will do a RTTI to make sure that the base class is actually pointing to class to which it's being downcasted to.

Well, that certainly does work -- and it crashes the program at runtime when its the wrong type of object as illustrated in the code I posted above. Using try/catch block doesn't catch the exception either.

void foo(Animal* anm)
{
    try
    {
        Cat* pCat = dynamic_cast<Cat*>(anm);
        pCat->Speak();
    }
    catch(std::bad_cast)
    {
        cout << "Wrong cast\n";
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can start by reading some of the Read Me threads at the top of this forum. They contain a wealth of information about books to buy and etc.

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

Actually I don't think you can because console programs don't have embedded icons like gui programs have.

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

You mean to tell us that you're a grad student in Political Science and don't want to talk politics :icon_eek: That's ok though.

Where are you from ?

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

Glad to have you at DaniWeb. We need more ladies here. :)

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

>> need to know what I need to start my first server ...
A computer with a monitor and a keyboard -- Oh yea, you'll also need a building to put it in and some electricity to run it.

A server can also be a waiter in a resturant. So I'd suggest you get a job in a resturant if you want to be a server.

Salem commented: :) anyone for tennis? +15
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No one can tell you a thing without knowing what program language you are using, what compiler, and what operating system.

Then we will move this thread to the approproiate board. It doesn't belong here in the lounge -- support questions are not allowed here.

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

I posted an example just a few minutes ago in this thread.

>>My point is i can achive the same by c style casting too...
Just change from static_cast<char*>(obj) // c++ style case
to (char *)obj; // c style case

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

Use an icon editor to create the icon then windows explorer to change the program's icon.

Or these links

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

>> don't want use langage VC++
VC++ is NOT a language but is a compiler produced by Microsoft. Don't confuse VC++ (the compiler) with C++ (the language).

And yes you can do network programming with Microsoft VC++ compiler as well as most other compilers. Look at these google links for example

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

lets say you have a base class called Animal and two derived classes called Dog and Cat. Casting a pointer of type Animal to Dog is unsafe because that might actually be type Cat. If there is something about Animal that will tell you whether it is a Dog or not, then make the test and typecast only if the test passes.

Run the example below and you will see that the function foo() cast the pointer to the wrong type of object.

#include <iostream>
using std::cout;

class Animal
{
public:
    Animal() { nLegs = 4; }
    virtual void Speak() = 0;
protected:
    int nLegs;
};

class Dog : public Animal
{
public:
    Dog() {};
    virtual void Speak() { cout << "Wolf\n";}
};

class Cat : public Animal
{
public:
    Cat() {};
    virtual void Speak() { cout << "Meow\n";}
};

void foo(Animal* anm)
{
    Cat* pCat = reinterpret_cast<Cat*>(anm);
    pCat->Speak();
}

int main()
{
    Dog dg;
    foo(&dg);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Its not in the makefile, but a difference in the code. Post the function header in the lib. the prototype in the header file (if you have one), and in the function call in the application program. Could be something as simple as const in one and not in the other.

sjcomp commented: Very helpful +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This is how I would do it, but there might be other ways.

int main()
{
    int ***arry;
    int f = 2, s = 3, v = 5;

    arry = new int**[f];
    for(int i = 0; i < f; i++)
    {
        arry[i] = new int*[s];
        for(int j = 0; j < s; j++)
        {
            arry[i][j] = new int[v];
        }
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

just specifiy the full path along with the filename, like this. Notice that you have to have two \\ as folder separators. ofstream out("c:\\mypath\\file.txt");

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

They all look valid function calls to me. But can't be sure because we don't have the function prototype for Test().

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

what programming language are you using ? Geek's Lounge is not the right place to ask that question, but we need to know how you want to go about doing that in order for us to move this to the correct board.

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

You will want to learn ODBC and SQL languages. ODBC is an old way to access modern databases, while SQL is the language used by most databases such as Access. But don't use Access in a web environment because its only good for a couple people at a time. Its not a very good multi-user database. You will want to use MySql or sometime similar.

If you grep for "ODBC c++ classes" you will find several, some free and others not free.

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

>>Can you try it on linux?
No -- I don't do linux :)

When I bump up the compiler's warning level I get these warnings

geom_Edge.cpp
d:\dvlp\test4\test4\geom_edge.cpp(7) : warning C4239: nonstandard extension used : 'argument' : conversion from 'geom_Point' to 'geom_Point &'
        A non-const reference may only be bound to an lvalue
d:\dvlp\test4\test4\geom_edge.cpp(7) : warning C4239: nonstandard extension used : 'argument' : conversion from 'geom_Point' to 'geom_Point &'
        A non-const reference may only be bound to an lvalue
geom_Point.cpp

Maybe that is what g++ is talking about ?

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

>>Ancient Dragon's first answer seems rather completely wrong
Possible, depending on the definition of "busy waiting". Using your definition I might just check the keyboard for input

while( !kbhit() )
{
   // do some processing
}

I agree with you that coding an empty function like the one you posted is a horrible thing to do because it consumes too much CPU time.

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

using VC++ 2008 Express I didn't get any errors or warnings on that code. I created a new project, added the four files to it, created my own main() which was an empty function, and it compiled ok.

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

forward declarations only allow you to declare pointers to the class. If you want to declare an actual object then you need to include the entire header so that the compiler knows that the class looks like. Maybe this will work -- make P1 and P2 pointers in the .h file, then move the class constructor to the *.cpp file where you can allocate memory for them. You also have to change the get functions.

#include <iostream>
using namespace std;

class geom_Point; //forward declaration

class geom_Edge
{
	geom_Point* P1;
	geom_Point* P2;
public:
	geom_Point getP1();
	geom_Point getP2();
	//default constructor
};

ostream & operator << (ostream &output, geom_Edge &e);
#include "geom_Edge.h"

// class constructor
geom_Edge::geom_Edge()
{
    P1 = new geom_Point;
    P2 = new geom_Point;
}

ostream & operator << (ostream &output, geom_Edge &e)
{
	output << e.getP1() << " " << e.getP2();
	return output;
}

geom_Point geom_Edge::getP1()
{
	return *P1;
}

geom_Point geom_Edge::getP2()
{
	return *P2;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Welcom to DaniWeb. If you want to talk politics you will get lots of responses in our Geek's Lounge. I don't know how IT can help you with that but please feel free to ask your questions.

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

>>I work in Visual C++ 6.
Bad, bad thing to use. Get into the 21st century and upgrade to VC++ 2008. Then you can do it like this:

But if you can't do that then here's a tutorial -- but be prepared for some very complex programming.

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

line 21: All that does is declare an array. Yet on line 27 you are attempting to sort it. Where are you copying the values of array1 into the array that was declared on line 21?

Also, you can't declare an array like that because count needs to be a const value. You have to use new to dynamically allocate the array double* fntArray = new double[count];

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

>>In the original post I mentioned that I have already overloaded << for Point.
Yes you did and I missed it.

>>Is there anything else I can check??
don't know without seeing the entire code. Try my first suggestion to see if that compiles.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
string ary[] = {"string1","string2" ...}
int n = sizeof(ary) / sizeof(ary[0]); // number of strings
srand(time(0));

int x = rand() % n;
cout << ary[x] << "\n";
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you have not posted any code so how in the world do you expect anyone to tell you what's wrong ?