NathanOliver 429 Veteran Poster Featured Poster

i noticed on line 17 you a creating a new SYM object. have you tried using the new keyword?

SYM * temp = new SYM[N];  // using the size you passed into the function for the array
NathanOliver 429 Veteran Poster Featured Poster

a way you can do this would be to have a void check function inside a while loop in your main function.

void CheckInput(char[80], bool*);

int main()
{
       char[80] cake;
       bool good = false;
       while (!good)
       {
              cout << "please enter a cake: "
              cin >> cake;
              CheckInput(cake, &good);
       }
       //...
}

void CkeckInput(char[80] cake, bool* good)
{
       //  run a switch checking cake agiants the valid choices
       // if the check succeds then set good to true otherwies do nothing
}

im not sure if you are using pointers though so if you are not this solution wont work.

NathanOliver 429 Veteran Poster Featured Poster

where are you setting the emp in the node. i see this block for file input

while (fin >> number)
        {
                head = new LISTNODE(emp , head);
        }

but with this you are not doing anything. first you need pull the information into your employee struct and then add it to you list.

NathanOliver 429 Veteran Poster Featured Poster

what exactly is you error?

NathanOliver 429 Veteran Poster Featured Poster

i found this site and it has g++ for Linux
http://gcc.gnu.org/wiki/GFortranBinaries

NathanOliver 429 Veteran Poster Featured Poster

also in the first program there is no memory leak.

NathanOliver 429 Veteran Poster Featured Poster

sorry but your post doesnt make sense. if we use 2/5 - 1/2 with your formula we get:
numerator = (2 * 2) - (1 * 5) = 4 - 5 = -1
denominator = (2 * 5) = 10
so your fraction should be -1/10. not sure why you are not getting it unless it has something to do with your simplify function

NathanOliver 429 Veteran Poster Featured Poster

the size you want for the substring should be 13 not 14. that should help

NathanOliver 429 Veteran Poster Featured Poster

yes it is. in order to do the comparison you need to tell the code what character to check. like:

for (int i = 0; i < somestring.length; i++
{
       if (somestring[i] == '"')
       {
              //...
       }
}
NathanOliver 429 Veteran Poster Featured Poster

what string are you using? std::string or something else?

NathanOliver 429 Veteran Poster Featured Poster

well if you want to check for a " in a string then you can write.

if (somestring[n] == ' " ')  // i put a space between the single quotes and the double quote so you could see it.  in your program just put '"'.
{
       //...
NathanOliver 429 Veteran Poster Featured Poster

i had a similar problem writing a string to a file and i got some good advice.

http://www.daniweb.com/forums/thread203217.html

NathanOliver 429 Veteran Poster Featured Poster

well im not sure what is going on. i wrote a simple test program and ran it and it works fine for me. this is what i did.

#include <iostream>
#include <string>

using namespace std;

int main()
{
	char * gen_arr[] = {
	"Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge",
	"Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", "Pop", "R&B",
	"Rap", "Reggae", "Rock", "Techno", "Industrial", "Alternative", "Ska",
	"Death Metal", "Pranks", "Soundtrack", "Euro-Techno", "Ambient",
	"Trip-Hop", "Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical",
	"Instrumental", "Acid", "House", "Game", "Sound Clip", "Gospel",
	"Noise", "AlternRock", "Bass", "Soul", "Punk", "Space", "Meditative",
	"Instrumental Pop", "Instrumental Rock", "Ethnic", "Gothic",
	"Darkwave", "Techno-Industrial", "Electronic", "Pop-Folk",
	"Eurodance", "Dream", "Southern Rock", "Comedy", "Cult", "Gangsta"};
	char country[30];
	cout << "enter the word Coutnry: ";
	cin.getline(country, 30);
	if (_stricmp(country, gen_arr[2]) == 0)
		cout << gen_arr[2];
	cin.get();
	return 0;
}
NathanOliver 429 Veteran Poster Featured Poster

alright sorry total brain fart. char * gen_arr[]; is right. i did a simple test on my machine where i made a variable char * country = "Country"; and the used country and gen_arr[2] in the _stricmp funtion and it was fine. im wondering how you are getting the value of value. is it a char array or a string as in std::string?

NathanOliver 429 Veteran Poster Featured Poster

that definition doesn't work to make a 2d char array. if you want a 2d char array you could say char * gen_arr[2][7] = {"String1","String2"}

NathanOliver 429 Veteran Poster Featured Poster

such as char gen_arr[][] ?

NathanOliver 429 Veteran Poster Featured Poster

when you are writing to the file you are using the memblock variable when you should be using sizeof(block) so that write knows how many bites to write to the file.

dst.write(block, sizeof(block));

also on line 15 you are using 4 for the size of test. are you sure that is the size you need? otherwise i would use the same size that you have for block of [memblock + 1].

NathanOliver 429 Veteran Poster Featured Poster

have you tried making your output stream a fstream like your input stream and using the write() function?

NathanOliver 429 Veteran Poster Featured Poster

my advice would be to add a member variable to the patient class of type doctor that you assign when you get a doctor. this way you could call the member doctors get fee function.

class Patient
{
public:
// ...
void SetDoctor(Doctor & doc) { doctor = doc; }
// ...
protected:
// ...
Doctor doctor;
};

double Patient::Billing() const
{
return doctor.get_fee_of_doc();
}
NathanOliver 429 Veteran Poster Featured Poster

but he will need one for class ClassB because it has an array of ClassA objects

NathanOliver 429 Veteran Poster Featured Poster

the reason you would want to make your own is that with c++ the default will make an exact copy of the class and you will have two classes that point to the same memory address's. now if you delete the pointer in one class then the other class will be pointing to memory that you have no idea what could be in it. with variables that are not on the free store it doesn't matter really except for good programing practices but with free store information it is really a must.

NathanOliver 429 Veteran Poster Featured Poster

well a really easy way to fix this is if you can use 2 one dimensional arrays then store the first column in one array and the other column in the second array

int column1[12], column2[12];
int i = 0;
// open the file
while (!inFile.eof()) // goes
{
infile >> column1[i] >> column2[i];
i++;
}

this will also make finding data int the separate columns a lot easier. the problem you were having with your 2d array was on the line while( inFile >> temp[i][0] >> temp[i][1]) . here you were writing data to places that didn't exist because the array was defined as temp[2][12] but this line was going up to temp[11][0] and temp[1][11]. the later was good but the first one you would want the i variable in the second part of the array like temp[0]. this way you would go up to temp[0][11] and temp [1][11]. i hope this makes sense.

NathanOliver 429 Veteran Poster Featured Poster

i take it you are trying to see if the user entered 150 or 175 as the rate and if they do not then tell them they have a wrong entry and re ask for the room rate a simple way for this would be to do this

int rate // this can be any type
cout << "Please enter the room rate: ";
cin >> rate
if ((rate != 150) || (rate != 175)// this will make sure you only get 150 or 175
{
// loop for the right response
NathanOliver 429 Veteran Poster Featured Poster

the prototype for SetEndOfFile is BOOL SetEndOfFile(HANDLE hFile); so you do not need to have BOOL SetEndOfFile(HANDLE hFile); all you need to do is write SetEndOfFile(hFile); and if you want you could assign the return value to a bool variable to check for success or failure ie.

bool isSet;
isSet = SetEndOfFile(hFile);
if (!isSet)
{
// do something..
}
NathanOliver 429 Veteran Poster Featured Poster

from what i can gather from my msdn you will need to read the file file before you write to it so that the file pointer is at the end and will put any new text after everything in the file. you can use the ReadFile() function to read all the data and move the file pointer to the end. hopefully this will help.

NathanOliver 429 Veteran Poster Featured Poster

the easy way for you to not use the lowest score when you calculate the average is to sort your array to have the lowest score in the first element then use a for loop and start at the element after that. example

int numberOfScores;
float average;
cout << "please enter the number of test scores to enter: ":
cin >> numberOfScores
float * scores = new float[numberOfScorse];
// ask the user for each score
// run the sort and have the lowest score in scores[0]
// then to get the average
for (int i = 1 /*start at 1 because 0 is the lowest*/; 1 < numberOfScores; i++)
{
        average += scores[i];  // this will sum up all the elements except the lowest
}
average /= (numberOfScores - 1); // divide buy the number of scores minus 1 because you dropped the lowest
cout << "The average score is " << average << ".\n";
NathanOliver 429 Veteran Poster Featured Poster

i would make sure that time1.h is in a directory where the compiler looks for the files to include. the compiler might not be finding the include file. I've had this problem with msvc 6.0 but I've never used g++

NathanOliver 429 Veteran Poster Featured Poster

u r talking about four million,thats completly out of range for an int declaration...........whether u take long int it will not work,becouse
long int don't have that much range in 32 bit processor..........
but it might work in 64 bit
u may try

the max of a 32 bit unsigned int is 4294967296 or 2147483648 for signed which is more than he needs. the formatting issue is the only problem.

NathanOliver 429 Veteran Poster Featured Poster

well a multidimensional array has a max that is equal to the max of each dimension multiplied together. so if your array is array[10][5][20] then you would do 10*5*20 to get the max which would be 10000. this works no matter how many dimensions you have. so in your program you would set maxN to the max of each dimension in your array times each other.

NathanOliver 429 Veteran Poster Featured Poster

when you use << it looks for a method to ouput the data. since you are trying to output the class the compiler looks for a method to ouput but since yo dont have one you are getting this error. you need to overload the << operator so it displays the data of the class.

// class functions declerations
friend ostream & operator <<(ostream & out, IntArray & array);
// more class functions
//...
//class definitions
ostream & IntArray::operator <<(ostream & out, IntArray & array)
{
 for (int i = 0; i < numElements; i++)
 {
   cout << data[numElements] << "\n";
 }
 return out;
}

not only will this ouput the data of the class but since it returns an ostream reference you can write statements like cout << a << endl << b << endl << c << endl; otherwise you would have to output each class one at a time

NathanOliver 429 Veteran Poster Featured Poster

it might be windows specific but I'm not sure. i am using Microsoft visual c++ 6.0 professional and found it in my msdn one day when trying to find an answer to this specific problem for use with a very basic login screen and it didn't care about case sensitivity in the passwords and user names. all of the code that i have made so far has been on windows machines so i couldn't tell you if it is portable to other OS's. i have include my string.h file so that you can see the function prototype. the function is marked with a comment for you.

NathanOliver 429 Veteran Poster Featured Poster

there is a function in the <string> header file called _stricmp that will convert all the characters to there lowercase. the function is defined as

int _stricmp( const char *string1, const char *string2 );

this function will return 0 if the strings are equal. less than 0 and greater than zero returns mean they do not match. to use this i would write

#include <string>
#include <iostream>

using namespace std;

int main()
{
string string1 = "abcd";
string string2 = "ABCD";
int equal;
equal = _stricmp(string1.c_str(), string2.c_str());
// using the c_str function here to pass the char array to the
 //function because it does not take in a string but a char
if (equal == 0)
cout << "the strings are equal"
else
cout << "the strings are not equal"
return 0;
}

hope this helps you out

Dave Sinkula commented: Bad advice in a number of ways. -4
NathanOliver 429 Veteran Poster Featured Poster

have you tried adding a cout statement before you assign the value to the array to make sure you are getting an assignment.

f_in.read((char *)&speech, 2);
cout << value[i] << "\t";  // show the value before assignment
value[i] = speech;
cout << value[i] << std::endl;
f_out.write((char *)&speech, 2);
NathanOliver 429 Veteran Poster Featured Poster

are you getting the same number for every value?
are you sure that the size of each element is 2?

NathanOliver 429 Veteran Poster Featured Poster

sorry i meant to do this

char ch;
ifstream fin(*infile);while (!fin.eof()){for (int count=0; count < 4; count++) {  for (i = 0; i < SIZE - 1; i++){fin >> inchar//...ifstream fin(*infile);
while (!fin.eof())
{
for (int count=0; count < 4; count++) 
{  
for (i = 0; i < SIZE - 1; i++)
{
fin.get(ch);
//...

I'm pretty sure that will work.

NathanOliver 429 Veteran Poster Featured Poster

well I'm not to sure about FILE but i know that if you do this you can loop through the file until the end.

ifstream fin(*infile);
while (!fin.eof())
{
for (int count=0; count < 4; count++) 
{  
for (i = 0; i < SIZE - 1; i++)
{
fin >> inchar
//...
NathanOliver 429 Veteran Poster Featured Poster

on line 47 you have

temp.estimatedTime = h.estimatedTime + h.estimatedTime;

all this is doing is adding the term h.estimatedTime to itself effectively doubling it. if you want to add the first and second terms you can do

temp.estimatedTime = this->estimatedTime + h.estimatedTime;

this will add both terms together if the data is public. if you want to keep the data private i would suggest writing some accessor functions like int GetEstimatedTime() {return estimatedTime } so you can get the private data.

NathanOliver 429 Veteran Poster Featured Poster

if you mean that you want to round the number to a specific number of decimal places you might want to make a char array and use _gcvt() to store in the number of digits you want. for your example if you want pi to 5 places you could do this.

const double fullPi=3.141592653589793;
char * pi = new char[8];
_gcvt(fullPi, 8, pi);

_gcvt() takes in a double and outputs the number of digits specified in the second term then it outputs the string into the char[] in the third term. for this you need to have an array that is big enough to hold the digits before the decimal place the decimal itself the number of digits after the decimal point and the terminating null at the end so in this case for 5 places you need a char[] of size 8.

NathanOliver 429 Veteran Poster Featured Poster

for this part of code

char * pChar[255];
pChar = new char[255];

you do not want to declare pchar with its elements. you save that for the new operator part. so you would want to do this

char * pChar;
pChar = new char[255];

also when you delete an array you always want to place the array operator before the name of the array. otherwise you will just delete the head of the array but the rest of it will still be sitting there in memory taking up resources until your application exits.
make sure you alway use delete [] variable_name; also it is always a good idea to set your pointer to null after deleting it. deleting a pointer that has already been deleted is guaranteed to crash your system but deleting a null pointer is safe.

NathanOliver 429 Veteran Poster Featured Poster

in your void viewAllInfo(Person year1[], int size) you are getting a redefintion error delete your decleration of i from this line. int m1, m2, m3, m4, i = 0; to get this int m1, m2, m3, m4; also in my compiler i hade to include the string header file #include<string> to make the cout statements dealing with strings to output

NathanOliver 429 Veteran Poster Featured Poster

well when i run the simulation it displays hex numbers for awhile and then it will show me 2 sets of hex numbers and then ask me to press enter to continue and every time i do it just does it again. not quite sure whats going on yet but ill get back to you tomorrow afternoon/evening with anything that i find.

NathanOliver 429 Veteran Poster Featured Poster

well now you have another beast to deal with. the best of luck getting it running.

NathanOliver 429 Veteran Poster Featured Poster

would you mind terribly much if you messaged me with the code attached so i could try something?

NathanOliver 429 Veteran Poster Featured Poster

alright. what is going on here i believe is that begin.sim[sim].field[x][y].rabbits is giving you a pointer of a pointer so to get down to the original pointer try *begin.sim[sim].field[x][y].rabbits i hope that this will work

NathanOliver 429 Veteran Poster Featured Poster

Thank you. okay to make sure you want pointer to hold the rabbit object right?

NathanOliver 429 Veteran Poster Featured Poster

could you please post the declaration of "pointer"

NathanOliver 429 Veteran Poster Featured Poster

well you could do this

ofstream fout("TheOneFile.txt", ios::app);
fout << something;
fout.close();

this way everytime you need to ouput something into the file you open it, store the information, then close the file. this way you can have every file of source code store information into the file without having to worry that another peice of code has access to that file. to be double sure always include this before trying to store to a file

if (!fout)
errorCondition = true;

you really can do anything if the oppening fails i just put this in as an example.

NathanOliver 429 Veteran Poster Featured Poster

If you want the address of the pointer you would want to say

pointer = &begin.sim[sim].field[x][y].rabbits;

that will give you the address of the pointer not the address that the pointer holds. hope thats what you wanted

NathanOliver 429 Veteran Poster Featured Poster

I would cycle through each letter in the string that was inputed an see if it was repeated then you will be down to at most a number of checks equal to the size of the string.