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

You can't use malloc() to allocate c++ objects like std::string, but use the new operator. This is more than likely the cause of your program crashing.

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

I don't think it would work here because it would not have enough traffic to make it viable. DaniWeb is devoted to IT related issues. I'm sure you can find other suitable web sites for help with electrical engineering.

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

I wouldn't use the terms "Old Testiment" and "New Testiment" because you will immediately get critisizm from the religious people. No point immediately discarding 1/4th the potential readership (and customers).

Alex Edwards commented: Whoo! O_O, good point! =) +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
bool test;
string input;

cout << "hi";
cin >> input;

if(input=="hi")
 test = false;

else
 test = true;

if(test == true)
 cout << "poop\n";
else
 cout << "wow\n";
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I guess you don't know how big a 6,000 page book is! I have a copy of "SQL, The Complete Reference", by James Groff & Paul N Weinberg, which has 998 pages and is 2 1/2 inches thick. Your book would be about 15 inches thick! I have never seen such a huge book.

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

bool is a variable that only contains 0 (false) or 1 (true). You use it only when you want something to be either true or false. I could also have written the while statement like this: while( done == false)

tatainti55 commented: Thanks +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1) Can I assume you have not tried to compile the code you posted? Or that you just ignored all compiler errors ? (Hint: Line 73 is wrong)

If you can print the information correctly using cout then you can print the same thing using any ofstream object -- cout is just another ofstream object. I suggest adding an ofstream parameter to print_inorder() then pass it along to the inorder() function so that the correct ofstream can be used.

void BinarySearchTree::print_inorder(ofstream& out)
{
  inorder(root, out);
  return results,results2;  // <<<<<<<<<< error here!
}

void BinarySearchTree::inorder(tree_node* p, ofstream& out)
{
   if(p != NULL)
    {
        if(p->left) inorder(p->left, out);
        out << " " << p->count << "   " <<  p->data << endl;
        
        if(p->right) inorder(p->right, out);
    }
    else return;

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

My guess is that the program needs to reinitialize some variables. But you can almost always avoid using the goto statement at all

bool done = false;
int response;

while( !done )
{
     response = menu();
     if( response == 2
     {
         done = true;
     }
     else
     {
          // initialize game variables here and
          // play game
     }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Welcome to DaniWeb. You need to make a post in our Project Partners Wanted board.

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

>> include <inomanip>
That file doesn't exist either. It's misspelled.

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

Instead of just asking us to do your homework for you, post what you have done and find out how to make it work the way you want it to work.

Salem commented: Absolutely! +22
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That compiler is not fully c++ compliant and contains several bugs. If you want to compile that then you may have to use a different compiler.

>>Also check the options of your VC6.0 to make sure that it is pointing to the correct include, lib and bin directories.

I tried to compile with VC++ 6.0 and mine failed too for the same reason. The problem has nothing to do with header files.

It will compile if you replace string in the structure with char*.

output:

Enter time you parked your car (ie 12 30 a): 12 30
a
Enter time you picked up your car (ie 12 30 a): 1 0 a
THE RATES FOR THE GARAGE LISTED IS:
Day: Wednesday
Rate: $12.50
TimeIn: 12:30am
TimeOut: 1:0am
Press any key to continue

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

>> ptrBase->member3
That doesn't work because base class knows nothing about the inherited classes. It has to be typecase to the desired class

int main(void) {
	Base ob1;
	Derived ob2;
	Base *ptrBase;
	ob2.member3 = 1;
	ptrBase = &ob2; // works fine
	cout << endl << reinterpret_cast<Derived*>(ptrBase)->member3 << endl;
	cin.get();
	return EXIT_SUCCESS;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can't put it in DLLMain() because just like any other function the object will disappear as soon as DllMain() returns. Instead, the object must be global. Then to make it visible to the application program you have two choices:
1) use __dllspec(__dllexport) tag __declspec( dllexport ) const char my_var[13] = "Hello World!"; or
2) create a *.def file and ass my_var to it

In the application program extern __declspec( dllimport ) const char my_var[13]; More info here.

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

A static class variable is like an ordinary global variable but has scope only within the class. Like global variables, there is only one instance of a static variable regardless of the number of instances of the class.

>> it complains about missing Count in DLListNode class...
Because you also have to declare it just like a global variable, but with class scope. Here is a simple example.

#include<iostream>
using namespace std;

class MyClass
{
public:
    MyClass() {x++;}
    ~MyClass() {x--;}
    static int x;
};

int MyClass::x = 0; // <<<<< declare class static variable

int main()
{
    MyClass a;
    cout << a.x << "\n";
    MyClass b;
    cout <<  b.x << "\n";

}
mrboolf commented: Really helpful and straight to the point. Thank you :) +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

use DirectX -- it has a bouncing ball example program (or it did some time ago)

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

line 42: since the array temp was not initialized, calling strlen() will produce unpredictable and unreliable results. You don't want strlen() of temp but sizeof(temp) so that it can be used in lines 45 and 46.

You can replace lines 42-47 with just one line char temp[251] = {0};

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

For the benefit of non-Americans, Senator Harry Reed (in the interview) is just flat wrong -- our taxaction is NOT voluntary and people have served prison time for not paying taxes. We can not tell our employers not to deduct taxes from our salary, nor can employers decide not to withhold them. Its only optional for companies that make less than some amount of money. Then at the end of every year we are REQUIRED to file income tax forms to calculate the amount of taxes owned for the year and either pay what we still owe or get a refund for paying too much during the year.

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

when I said you need professional help I meant for you to go see a headshrink, not use google.

>>sorry to trouble you
You didn't "trouble " me -- we are here to provide IT-style help, not be your psychiatrist

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

The way I understand it is all you have to do is create the functions you mentioned then move the code from the switch statement into the appropriate function, finally add function call inside the switch statement. Don't worry about menus etc until you get the hang of writing functions. Just make the changes one function at a time to keep you from getting confused and overwhelmed. Example:

void AreaCircle()
{
    cout << "Enter the radius of the circle: "; 
    cin >> radius;
		
    if (radius < 0)
    {
        cout << "Number must be greater than 0. Try again" << endl;
    }
    else 
    {
       circleArea = PI * pow(radius, 2);
       cout << "The area of the circle is: " << circleArea;
   }

    cout << endl;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Go get professional help -- we aren't qualified to give you the help you need.

R0bb0b commented: Funny, I googled help me. and daniweb isn't even in the first 5 pages +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I didn't get a score -- just this message:

You are a hardheaded realist who sees the world pretty much as it is. No room for fantasy--you're practical to a fault. You might be seen as a cold fish when it comes to amorous notions. You're "thing oriented" rather than "people oriented." You may need to thaw out.

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

convert to integer

int main()
{
    double n = 923.15;
    int x = (int)n/100 * 100;
    cout << x << "\n";

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

try this:

while (peopleCount < FINALPOP)
	{
		 annualGrowth = annualPerc * INITPOP;
		 peopleCount += (int)annualGrowth; // + INITPOP;
		 yearsLeft = FINALPOP / (float)peopleCount;
		 // peopleCount += peopleCount;
		 cout << peopleCount << yearsLeft << endl;
	}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is how to round down

#include <iostream>
#include <cmath>
using std::cout;

int main()
{
    double n = 923.45;
    double intpart;
    double fractpart = modf(n/100, &intpart);
    cout << intpart * 100 << "\n";
	return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Is it possible to allow members to edit the text that is highlighted in yellow, such as this one in a recent thread ? The OP (and me) are just SOL if he/she doesn't like the way it turned out. And Preview Post before submitting doesn't show it either.

http://www.emailads.biz
Ad Placements Available: daily
Monthly Uniques: 5,000
Payment Terms: prepayment

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

If you want to put 5 spaces between columns, and the digits left-justified in the field, then use the - (minus) to left-justify printf("%-5d%-5d%-5d", 0, 1, 2);

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

When I was young Art Linkletter had a weekly tv show Kids Say The Darndest Things. Here are some links YouTube links for your enjoyment.

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

what about printing in columns and rows
012
0123
012
01
01
01

you mean like this?

0    1    2
0    1    2    3
0    1    2
0    1
0    1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you can't because you can't stuff a whole string into a single character. If this is about some error message you got, then post the error message along with the code you wrote.

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

Why are you using wchar_t ? Its a single character, not a string, so if(com = 'deldir.') { isn't going to compile correctly. And deldir isn't a single character either, so it should be in double quotes like any other normal string literal in C/C++, not single quotes.

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

after entering an integer the program leaves the '\n' in the keyboard buffer. When the next getchar() is called it gets that '\n' from the buffer instead of waiting for user input. To correct this add getchar() after scanf("%d", &consump);

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

>>catch(std::char * s)

Error most likely because there is no such thing as std::char. change to this and retest: catch(const char* s)

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

use ofstream instead of ostream. Then include <fstream> instead of <ostream>. Finally, add using statements after the include files

#include <fstream>
using std::ofstream;
using std::ifstream; // if you want this
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

try this: printf("%03d", num); In "%03d", the 3 means minimum of 3 digits, 0 means print 0's if num is less than 3 digits. So num = 1, that will print 001

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

where did you get that address from? 68FCH == 26876 decimal. If that's the byte offset in the file where that value is found, then you should be able to just seek to that position and read that byte.

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

Here's how -- use setfill() and setw()

#include <iostream>
#include <ctime>
#include <iomanip>

using std::cout;
using std::cin;
using std::endl;
using std::ostream;
using std::setw;
using std::setfill;

ostream& operator << (ostream&,const tm&);

tm mytime; // not quite safe

int main(){


 //   tm mytime; // safer implementation
    mytime.tm_mday = 10;
    mytime.tm_mon = 5;
    mytime.tm_year = 2008;
    mytime.tm_hour = 3;
    mytime.tm_min = 8;
    mytime.tm_sec = 30;

    cout << mytime << endl;
    cin.ignore();
    cin.get();

    return 0;
}

ostream& operator<<(ostream& out,const tm& theTime){
    out << setfill('0') << setw(2) << theTime.tm_mon << "/" 
        << setw(2) << theTime.tm_mday << "/" 
        << setw(4) << theTime.tm_year;
    out << setfill('0') << setw(2) << "\t" 
        << setw(2) << theTime.tm_hour << ":" 
        << setw(2) << theTime.tm_min << ":";
    out << setfill('0') << setw(2) << theTime.tm_sec;
    return out;
}
Alex Edwards commented: Whoo! Thanks =) +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1) prompt.h and prompt.cpp -- you need to specify function return values.

2) program is using uninitialized struct member in function Add_vcd(). You can fix that problem by adding a class constructor to the structure which initializes it.

struct vcdDB_T{
       vcdRec_T vcdRecords[maxSize];
       int vcdIndex;
public:
    vcdDB_T() {vcdIndex = 0;} 
};

There appear to be other problems too, such as displaying junk records.

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

Alex: using stringstream as you did is not necessary -- cout already knows how to do it.

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

That wasn't what I meant -- There must have been more the the instructions your teacher gave you what what you posted because what you posted doesn't make any sense. Post exactly the words given to you.

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

I'm not sure what your program is attempting to do, but I do know it contains at least two memory leaks. You use new operator to allocate memory to a Data pointer but never delete[] it before leaving the switch statement.

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

Also please post actual text of the assignment, not how you interpreted it.

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

post what you have tried. And post an example data file.

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

Work through the error messages one at a time. The first error is normally what's wrong. Correct that error then recompile -- you will get a lot fewer error messages that way.

For example: line #2 of the code you posted is probably wrong. System header files are enclosed in < and > brackets, not quotes. #include <iostream> line 12: you have an extraneous ; just before the += operator

line 13: you used the wrong brace -- should be { instead of }, and your program is missing the matching }

for (int idays = 0);idays;<14;idays +=1)
{
    cin >>  fHoursworked;
    fTotal += fHoursworked;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

instead of system(pause>nul) why didn't you just simply use cin.get() ? you wouldn't have to have done all that net searching :)

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

struct tm: is just a structure that can be use like any other structure. The localtime() function takes a time_t object and returns a pointer to a struct tm.

time_t now = time(0); // get current time
struct tm* tm = localtime(&now); // get struct filled out

cout << "Today is " 
    << tm->tm_mon+1 // month
     << "/" << tm->tm_mday // day
      << "/" << tm->tm_year + 1900 // year with century
     << " " << tm->tm_hour // hour
     << ":" << tm->tm_min // minute
     << ":" << tm->tm_sec; // second

mktime: does just the opposite of localtime(). It takes a struct tm object and converts it to time_t. In addition it may also normalize the struct tm object. Lets say you want to get a struct tm and time_t for some future date, say one month from now. To do that, you first call localtime() as shown above, add 30 days to the tm_mon structure member, then call mktime() to normalize the structure members. mktime() will take care of insuring the structure contains the correct month, day and year (such as for month and year roll-overs).

difftime: simply returns the difference between two time_t objects. See example program here.

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

Sorry, I'll have to get to this tomorrow evening if someone else has not answered your questions by then.

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

The instructions you originally posted are very confusing. Is that the exact wording of the assignment, or just how you interpreted it. Please post exact assignment.

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

If you want to start discussing computer programs then I guess I'll have to move this thread back to the C++ board. At the start, I moved it here because it seemed to have little, or no relation to c++, but I may have been incorrect. There is nothing wrong with what you have discussed here but its confusing to know just where to put this thread. I don't have a problem moving it back to c++ as long as that is what you want to discuss now.

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

In Dev-C++ IDE, go to menu Tools --> Compiler Options. then in each of the tabs make sure that it shows the full path to evrything. Such as Binaries: c:\dev-cpp\bin. There are some instructions on bloodshed.net's forums that says Dev-C++ has some problems on Vista and that's the way to fix them. Worked for me :)