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

you are missing a header file -- see example program here

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

lines 214-218: This will not work because the new operator does not return 0 when memory allocation fails -- it throws an exception. If you want to check for that then you need to use try/catch blocks.

The code you posted is a good example of the MISUSE of unions. If you (or your instructor) had used base class and inherentence then you would not need that DataType structure at all nor would you need all those overloaded methods such as lines 76-79.

As for your actual problem, don't know the answer because we don't have all the code to compile and test.

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

TextPad is not an IDE for compilers, but just a text editor. If you want to learn c++ then use a real compiler, such as free VC++ 2008 Express

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

how did that even compile? It is missing two closeing } character. Assuming that is just a posting error the code looks ok to me.

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

cin >> name >> lastname;

would work just fine too

Not for "Hillary Rodham Clinton"

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

There are many ways to implement it, here is just one of them.

If you want to store information in the registry instead of ini files then here is a good c++ class, although there are many others.

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

>>Does CWnd::GetClientRect() include the toolbar region?
Not sure if it does or not. Try using CWnd::GetWindowRect() and see if that fixes the problem.

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

your implementation doesn't work because it doesn't allocate memory for the two strings. Here is one way to implement it

const int MAXCOMMENTSTRING = 255;
class StringValues
{
public:
    StringValues()
    {
        Initialize();
    }
    StringValues(StringValues& s)
    {
        Initialize();
        strcpy(Name,s.Name);
        strcpy(Message,s.Message);
    }
    ~StringValues()
    {
        delete[] Name;
        delete[] Message;
    }
    char *Name;
    char *Message;
private:
    void Initialize()
    {
        Name = new char[MAXCOMMENTSTRING];
        Message = new char[MAXCOMMENTSTRING];
        memset(Name,0,MAXCOMMENTSTRING);  // optional
        memset(Message,0,MAXCOMMENTSTRING); // optional
    }
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

OOps! I think this is wrong

if(i != line) // if error
    return ""; // return blank line
return current_line;

should be this

if(i == line) // if error
    return ""; // return blank line
return current_line;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

post code you tried because it does work, I've used it hundreds of times.

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

trig will help for the math part but is useless for the gui part. What you want is an easy way to draw pie charts in C or C++. Read some of these google links.

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

Its not necessary to call chdir() in order to complete your assignment.
Example code snippet here. That code snippet recursively parses the entire directory path without using chdir(). All you have to do is stop the recursion when the appropriate path number has been found, then list all the files in that directory.

That code snippet was written for c++, not C, but the concepts are nearly the same. To convert it to C just delete the vector parameter and pass only the string as a character array.

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

The >> operator stops at the first space. To get everything you need to use getlin(). There are two versions: one for std::string and the other for character arrays.

cout<<"ENter name"<<endl;
getline(cin, name); // assum name is std::string

cin.getline(name, sizeof(name)); // assumes name is a character array
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

since this is c++ why use pointers? Just make name and message both std::string and that will probably solve the memory leek problemn.

Niner710 commented: Thanks for all your help. You are da man! +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Your last statement is how its normally done. Create one object then call all its methods as necessary. If you declare the methods static then you don't have to create an instance of the object in order to call the function

class A
{
public:
   static int getBeta();
};

int main()
{
    A::getBeta();
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

int level = atoi(argv[2]);

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

which part of USA is Scottland in ? Never heard of that state. :)

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

The program won't work if the file has fewer than line number of lines. Here's one way to correct that

int i = 0;
while(i < line && getline (current_file, current_line))
    ++i;
if(i != line) // if error
    return ""; // return blank line
return line;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Maybe you are using the wrong compiler. Download VC++ 2008 Express and compile your program for UNICODE (which is the default with that compiler)

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

line 36 in your post should be int FHF::m_id = 0; You have to declare it with a data type just like you would any other global variable.

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

gee whiz!! can't you even use google?

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

you will have to use some sort of gui libraries and/or compiler. Depends on your operating system.

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

using ctime functions will consume a lot of CPU time. Instead its better to call the os Sleep() function (MS-Windows) or sleep() (*nix).

#include <iostream>
#include <windows.h>
int main()
{
    while(true) // infinite loop
    {
         system("start alarm.wav");
         Sleep(30 * 1000); // delay 30 seconds
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

lines 13 and 14 are in reverse order. The { goes after the while statement, not before.

line 28 -- break -- is wrong because it is not inside any loop where a break is valid.

Here is how the function should work

top of loop
    enter variable x1
    enter variable x2
    are x1 and x2 the same and negative
    yes, then exit the loop
    multiply x1 * x2
end of loop
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can do it yourself. Just add another } at the end of the last function. One keystroke!

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

Same problem -- missing the closing } for the last function in your program.

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

You can not do that with your compiler without downloading the Windows Platform SDK as I said in my previous post. Is your teacher really that stupid to realize that? I think you should probably be using the student edition of that compiler, which is the same as the Pro edition that includes everything you need, but costs under $100.00 USD.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
#include <iostream>
using namespace std;

int calChol ()
   {
int score;

cout << "What is your cholesterol score? " ;
cin>> score;

cout << "Your cholesterol score is: " <<score <<endl;

       if (score<100)
       cout << "Your score is optimal.   ";
       if (score<130 && score>99)
       cout << "Your score is not optimal.   ";
       if (score<160 && score>129)
       cout << "Your score is borderline  high.";
       if (score<190 && score>159)
       cout << "Your score is high.   ";
       if (score>189)
       cout << "Your score is very high.   ";

return 0;
   }


int main()
{
    calChol();
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>.I am re-posting my code
This is your first post -- so how can that be ???

>>The code runs correctly, but the ending balance, after all the withdrawals, is incorrect

Then it doesn't run correctly, now does it??


What compiler are you using? VC++ 2008 Express produces a couple warnings that are really errors. You need to correct them.

1>c:\dvlp\test1\test1\test1.cpp(93) : warning C4700: uninitialized local variable 'total_deposits' used
1>c:\dvlp\test1\test1\test1.cpp(117) : warning C4700: uninitialized local variable 'total_withdrawals' used
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You have to download and install the Windows Platform SDK free from Microsoft. Or download and install VC++ 2008 Express, which has what you need.

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

You didn't look very hard did you??? Look just above the line that contains the error -- there is a missing } to close the previous function.

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

Must be your browser -- it looks normal to me.

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

I don't get that problem with either IE7 (64-bit version) or FireFox version 3.0.3

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

About program formatting: Don't write a program that is straight down the left-hand side of the screen like you have posted. Indent the lines so that they are easier to read and understand.

About functions -- see How Stuff Works

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

Error 1: that error message always means that you have mis-matched { and } or parentheses. Count them and make correction.

Error 2: correct error #1 and this will be fixed too.

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

>>for(int i=0; int j= MAX-1;i<MAX; i++, j--)

That's the wrong format. use a comma after int i = 0 , not a semicolon and don't use int j

Two more errors:
1) you need to use { and } for multi-line statements
2) You have i and j in reverse order.

for(int i=0, j= MAX-1;i<MAX; i++, j--)
    {
        cout<<Input_String<<endl;
        Output_String[i] = Input_String[j];
    }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Seniors are allowed to have senior moments!

That may be true, but do we really want a President who has to many of them ???

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

>>I am new to C++ and am not currently in a class teaching it
OpenGL requires at least a basic understanding of c++. So if you don't have that then wait until you have completed a couple semesters of c++ or read/studied the textbook. No one here is even going to attempt ot explain OpenGL to you when you don't even know how to write a Hello World c++ program.

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

word alignment -- click here

>>Which Library do we work perfectly with a big integer
There are no standard c or c++ libraries that will do that. But click here for others.

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

>>Dudes Wuudup??
This isn't a chatroom. Write in English, not some sort of chatroom talk.

Assuming the target operating system is MS-Windows, read this tutorial.

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

you can not copy one character array to another using the = operator -- that only works with std::string.

The assignment wants you to copy the string in reverse order. The only way to do that is one character at a time, something like you did in the previous line when you displayed it in reverse order. When doing it one character at a time you can use the = assignment operator. Something like this, where s2 is the original string and s1 is the new string.

for(int i = 0; j = MAX-1; i < MAX; i++, j--)
   s1[j] = s2[i];

You can also do it with pointers

char* p1 = s1; // new string
char* p2 = s2 + strlen(s2); // original string
while( p2 > s2 )
   *p1++ = *p2--;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 28: remove void -- when calling a void function just have (), such as displayMenu(); line 40: function name is misspelled. Check capatialization.

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

or for UNICODE

TCHAR str[] = _TEXT("Hello world!");
  AfxMessageBox(x);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

write a recursive function to print the numbers.

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

and it should not be named "isPrime", because that isn't what it really does...

Hopefully he is not done writing the function.

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

evaluate the parameters and return the one that has the smallest value. For example, if the two parameters are 1 and 2, the return value will be 1.

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

He is asking you to write two functions named min -- The parameters to one of the functions will be two integers, while the parameters to the other function will have three parameters.

That is called function overloading -- more than one function with the same function name but different parameters.

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

I only carry one credit card -- leave the other one million cards on my bedroom dresser. I carry it to buy gas and other things I see while shopping. Then I always pay the entire balance when I get the bill so that I don't have to pay intgerest.

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

line 8: you have to declare a variable name inside the parentheses.

line 26: else should not be capitalized.

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

Your program has mismatched { and }. If you would use better formatting then such errors will be easier to find. As it is, it is very difficult and time consuming to find matching { and }. Here is an example of what I suggest:

for(i=1; i <= totalDates; i++)
{
    cout << i << "\t";
    dayCount++;
    if (dayCount==7)
    {
        cout << "\n";
        dayCount=0;
    }
    //output the calendar below
    cout << "Do you wish to see another month? Y/N or y/n?\n";
    cin >> flag;
		
    //check if the user wants to continue or not
}