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

The express editions of VC++ don't have a resource editor or compiler either but you can get free ones from google links. Dev-C++ doesn't have one either, I don't know about the other compilers Vernan mentioned.

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

menu items 4 and 5 are probably the most difficult and I would leave them to last. But the others aren't all that hard.

Take #1 -- append text to the end of a file. The answer to that is all in how the output file is opened. Look at the list of open flags and read their descriptions. One of them, ate says that the text will always be written to the end of the file. That means the file would be opened like this: ofstream out("filename.txt", ios::ate); .
Now each time you write something to that stream it will be appended to the end of the file.

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

VC++ 2008 Express is free for the downloading from M$. It doesn't support MFC, otherwise its nearly identical to the other paid versions. You can also download free Visual Studio C# and VB compilers.

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

this is a hidden parameter that is passed to every non-static method of a c++ class. It is used to point to a specific instance of a class and all its data object. In your specdific problem FindParent() is called from a specif node in the list, and the this parameter that is passed to that method by c++ is a pointer to that node.

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

Oh I see you want to store it in a character array with those leading 0's ? In c++ you would use stingstream class which works on strings just like fstream works on files

#include <sstream>
// other includes here
<snip>
int main()
{
    int number = 12;
    string line;
    stringstream stream;
    stream << setfill('0') << setw(4) << number;
    stream >> line;
    cout << line << "\n";

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

take the program you have and strip out all the calls to graphics.h functions and what is left is what you probably want to incorporate into your VC++ program. My guess is that there is other code in that program to support the graphics functions which you will not need either. The main things you want to keep is the algorithms used to make the calculator work. BTW I've never written one so I can't help you with that.

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

Padding integers with 0 to the left is a display thing only -- internally integers do not have leasing zeros. How to make them depends on how you are displaying them, such as are you using printf() or cout ?

int number = 12;
printf("%04d", number);

cout << setfill('0') << setw(4) << number << "\n";
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Neither flush() nor fflush() are used on input streams. Read this for how to flush input streams.

>>both do the same functions
Yes -- flush() is used by c++ streams in <fstream> and fflush() is used by C streams declared in <stdio.h>. Both flush the output stream.

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

i have a small problem in my ass and i dont know how to solve it

That's not very descriptive of the problem. You need to be a bit more specific about what you can not do or understand ?

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

lines 20 and 23 are wrong. Remove the word typedef from each of those two lines.

lines 31, 32, 64 and several others are just a huge mess. Put each of those statements that end with semicolons on different lines so that your program is easier to read. It not qute to jam all those statements on the same line and professional programmers rarely ever do that either.

I don't know what you mean by "integer overload". There is no such thing. The only places I see that variable are lines 29, 69 and 74. And I can't tell (due to horrible coding style) what it is that you are trying to do with it. A few comments is in order in your program.

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

>>void InsertData(vector<Book> &Insert)
Nothing wrong with passing the entire array by reference if the function needs it.

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

Pass the object by reference so that ChangeAdr() can change the original Book entry. The function is void so it does not return anything.

void ChangeAdr( Book& bk)
{
    getline(cin, bk.Address); 

    // This is where I come up short
    // How do I return the new adr. to Person[0]
//
// You don't -- that's what pass by reference does.
}

int main()
{
     vector<Book> Person;
    <snip>
    ChangeAdr( Person[0] );    
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't know what happened but about an hour or so ago the submenus stopped working unless I click on the main menu. For example, I can't get the dropdown menu unless I first click the Software Development menu. After than, the submenus all appear normally until I post a response in one of the threads. And then they stop showing up again.

The thumbnail is the only way I can get submenus

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

I have edited the progarm to alloacet space for more than one character. but it's still not working.

the code is as below. here i have assumed that user will not type more than 20 letter name or number. but the loop used by me is running for 20 times and is asking for 20 characters. i wanted that user could type as many as 20 characters. if he enters only 4 letter name than even it stops and ask for the last name. but i'm not able to make it possible...

the code is as follows:

void addBlackBook(char firstName[], char lastName[], char phonenumber[], ofstream& outFile, int& choice){

                        cout << "Type the contacts first name:\n";
                        for (int i=0; i< NUMBER; i++){
                                cin >> firstName[i];
                        }
                        cout <<"Type the contacts last name:\n";
                        for(int i = 0; i < NUMBER; i++){
                                cin >> lastName[i];
                        }
                        cout <<"Type the phonenumber\n";
                        for(int i = 0; i < NUMBER; i++){
                                cin >> phonenumber[i];
                        }
                cout << firstName[i] << lastName[i] << phonenumber[i] << endl;
                outFile << firstName[i] << lastName[i] << phonenumber[i] << endl;
                selectionMsg(choice);

Why the hell did you do that???? Put that back the way it was -- without the loops and the way I showed you to do it. The cin function is pretty darned smart and doesn't need those loops to get characters from the keyboard. So stop making things worse then you had them.

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

>>but tell me, how does one come to recognize something like that
Experience, practice, practice, and more practice -- thousands of hours of coding.

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

Oops! see thumbnail

And now there are no drop-down menus either.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
void onedie::rollit()
{
	srand(time_t(NULL));
	result= 1 + rand() % 6;
}

Problem might be here -- move that srand() line to be one of the first lines in main() function. It should be executed only once during the lifetime of the program.

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

it's going to look an awful lot like the other two loops except with the allresults array isn't it?

probably

0012FBF0
Press any key to continue . . .

that was the result of the code from the last post

Ok, so I was wrong -- that is the address of the first element of the array, not its value.

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

>>cout << allresults << endl;
That doesn't display the array but only the first element of the array. You need to create a loop and display each element one-at-a-time.

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

>>Why is the derived destructor not in the output. It does appear when using the keyword virtual both the destructors.

You got it! :) That's why we use virtual destructors. I think there is an explaination for that behavior in the link I posted.

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

lines 19 to 21 are wrong -- that is only allocating one character to each of those variables. You need to make them arrays, like this: char lastname[20]; And line 55 is also wrong -- I think you had it right the first time void addBlackBook(char firstName[], char lastName[], char phonenumber[], ofstream& outFile, int& choice){

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

AD, does that increment the different elements of the results array so you know which numbers are rolled how many times? I used the switch because that's what the prof has in the lesson plan, but I'm just as keen on keeping things simple.

I just looked at that switch statement and saw that it can be greatly simplified. Or something like this:

for (int i=0;i<rollsize;i++)
{
     int index = rolls[i] - 3;
     allresults[index] = allresults [index]+1;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you don't need that switch statement at all

for (int i=0;i<rollsize;i++)
{
        allresults[i] = allresults [i]+1;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

as suggested before you don't need that for loop. Just ask the three questions

cout << "Type the contacts first name:\n";
cin >> firstName;
cout <<"Type the contacts last name:\n";
cin >> lastName;
cout <<"Type the phonenumber\n";
cin >> phonenumber;
//
// You also need to separate the names with a space
outFile << firstName << " " <<  lastName << " " << phonenumber << "\n";
selectionMsg(choice);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

See the example I posted in post #4 of this thread.

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

>>First off all; I apologize for my poor english skills, i'm from sweeden'
You are doing great so don't worry about it.

There are a couple ways to mondify the data in the vector

int main()
{
    vector<Book>  Person;
    Book x;
    cout << "Enter name: ";
    getline(cin,x.Name);
    cout << "Enter address: ";
    getline(cin,x.Address);
    cout << "Enter phone number: ";
    cin >> x.Phone;
    Person.push_back(x);

    // Now change the address
    cout << "Enter address: ";
    getline(cin,Person[0].Address);

    // Another way to change the adress
    vector<Book>::iterator it;
    it = Person.begin();
    cout << "Enter address: ";
    getline(cin, it->Address);



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

As I said in my previous post, you CAN NOT USE those character arrays like that. firstname[20] is only one character so cin will not accept more than one character.

>> if i do then it won't be like what i want to do
Then you want to do the wrong thing. Your design is flawed because you can't do it like that.

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

I got it to compile without error. Problem seems to be here

#ifndef THREEDICE_H
#define THREEDICE_H

#include "onedie.h" // <<<<<<<<<<<<<<<<<< ADD THIS LINE

class threedice
{
	public:
		void rollem();  	  
		int getsumFaces();
		
	private:
		onedie die1;
		onedie die2;
		onedie die3;
};

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

If there's a large amount you could just attach the code. Hit the "Go Advance" button, scroll down to load attachments.

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

Post code. Its impossible for us to evalate the error messages without it.

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

There are several problems in the code you posted. Delete lines 3 and 8 because they are incrementing j outside the normal loop counter. Then on lines 4, 7 and 10 remove the [20] so that they look like this: cin >> firstName;

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

void statistics (int rolls[];int rollsize; int rollresults []) You're supposed to use commas to separate the parameters, not semicolons. And if that line is the start of a function where are the { and } at the beginning and end of the function?

henpecked1 commented: very helpful, extremely patient +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

variables _score and _tempscore -- why use new to allocate only a single character? That seems like such as misuse of dynamic memory allocation. And those two variables appear to be used without ever initializing them to anything. Is there code that you didn't post that actually sets them to something ?

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

>>but my inner loop for j is working again and agian instead of just working for 3 times.

are you talking about function addBlackBook() ? Of course it does because you told it ro run that j loop 500 times (line 56)!

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

I have all the original Planet Of The Apes movies. Didn't like the remake.

Swamp Thing was a low-budget movie that made tons of money.

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

IMO -- In My Opinion

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

where have you looked? Did you try google?

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

The first one only looks more efficient, but IMO the second one is because you can reference matrix just as you would any normal 2d array matrix[i][j] = 0;

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

give the text file a *.cpp extension then call your compiler to comple it. g++ might be a good one to use for this because of the extensive make file you can create which will tell the compiler how to compile it.

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

Did you read the link I posted ????

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

>>txt += INTTOCHARP(ballcount[0]);
In COUNTBALLS() -- INTTOCHARP() allocates memory with new but is never deleted.

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

line 14: use a different loop counter because that is destroying the value of n that you type in on line 11. Example: for(int i = 1; i <= n; i++){ line 16: replace n in the call to fib with the loop counter.

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

do you know how to write a loop?

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

why don't you put the call to fib() in a loop and pass the loop counter in the parameter

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

line 15 is still wrong -- what is it that you want to do when the value of num is odd ? I know you don't want to open the output file because you already did that at line 9. Someone else already gave you a hint of what to do in your other thread about this same program.

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

you can't write std::string objects to a binary file like that. The easiest way to simplify your program is to use a char array instead of std::string. Now in the class constructure initialize that char array to all 0s.

class Rivera
{
public:
	Rivera();
	
	void setKey(const int);
	int getKey() const;
	
	void setWord(const string&);
	string getWord() const;
	
private:
	int id;
	char palabra[13];
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
while ( invoiceInitilization != 'y' || invoiceInitilization != 'Y'
			   || invoiceInitilization != 'n' || invoiceInitilization != 'N' )

Those should be && operators, not ||.
You can simplify that by converting to either upper or lower case so that you don't have to test for all 4

while( toupper(invoiceInitialization) != 'Y' && toupper(invoiceInitialization) != 'N')
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Ok that compiles without errors/warnings now. The problem the display function doesn't work is because the Rect class constructor is wrong. Here is one way to correct it

Rect::Rect (int len,int width)
   {
	   this->length = len;
	   this->height = width;
	   this->fillChar = '*';
	   this->borderChar = '+';
   }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

OMG I take it you haven't even attempted to compile that code because it is just littered with errors. Fix the errors then come back to us, post new code and questions. I started to make some corrections but gave up not because I didn't know how to correct them but because it isn't work my time and effort when it is obvious you haven't bothered to do your job.