NathanOliver 429 Veteran Poster Featured Poster

@ Suzie999 the OP also said this

However one of the functions doesn't have a length passed with the other parameters!
char arrayX(char a[], char v)
Where you are asked to find amount of times value (v) is in the array.

He is trying to write a function to deal with an array where he is not getting a size of the array. If there is not a sentinal value in the array to mark the end there is no posible way to find out the size of the array that is standard conforming and portable. All you get in the function is a pointer to the first value of the array.

NathanOliver 429 Veteran Poster Featured Poster

Are you trying to run the exe file and getting this error? You might need to have the dll in the folder the exe file is in.

NathanOliver 429 Veteran Poster Featured Poster

Suzie if you have windows 7 go into the folder that holds the files for your project. Right click on a blank space and go to properties. in the properties page go to the previous version tab. It should have a list of different versions if you have volume shadow copy turned on.

NathanOliver 429 Veteran Poster Featured Poster

As far as i know there isnt a backup of the file. You might be able to get away with restoring the file windows if you have Shadow copy turned on? What OS are you using?

NathanOliver 429 Veteran Poster Featured Poster

To display it should look like this

std::map<std::string, double> milesto;

// load milesto

for(std::map<std::string, double>::iterator itr = milesto.begin(); itr != milesto.end(); ++itr)
{
    std::cout << itr->first << "\t" << itr->second << std::endl;
}

Also notice how I used ++itr instead of itr++. Using the preincrement operator will make the code slightly more efficent since it is not a built in type. Not a big deal but it is something to consider.

NathanOliver 429 Veteran Poster Featured Poster

line 9 should be

 std::cout << "You entered" << date;

You only need to call cout once.

NathanOliver 429 Veteran Poster Featured Poster

Could you get away by just having a stringstream object in your tokenizer class? What other functionality does PushbackReader offer?

NathanOliver 429 Veteran Poster Featured Poster

It is a shame schools are teaching with 20 year old compilers.

NathanOliver 429 Veteran Poster Featured Poster

Take at look at this and see how it can help you out.

NathanOliver 429 Veteran Poster Featured Poster

Okay. So what do you have so far?

NathanOliver 429 Veteran Poster Featured Poster

In your second for loop you are calling join(). join() blocks the current thread and waits for thread you called join on to complete. Im pretty sure this is where you are getting slowed down.

NathanOliver 429 Veteran Poster Featured Poster

I could be mistaken but if you have a quad core processor you should be able to run 4 threads at the same time. With the way you have your code written right now you start all 100 threads and then right after that you call each thread and wait for it to finish before you go to the next thread. If you have a lot of othere processes running in your system then this could effectivly keep everything running on a single core. You might be able to pull the threas using joinable() but that could also lead to problems.

NathanOliver 429 Veteran Poster Featured Poster

What is the type of DESTINATION?

NathanOliver 429 Veteran Poster Featured Poster

The way you have your code now if either stream fails it will end the loop. The problem is you arent doing anything after that. I would do this a little differently. Look at how this works.

while(getline(firstFile, line1) && getline(secondFile, line2))
{
    thirdFile<< line1 << endl << line2 << endl;
}
if(firstFile.fail() && !secondFile.fail())  // if first file ended first
{
    while(getline(secondFile, line2))
    {
        thirdFile<< line2 << endl;
    }
}
if(!firstFile.fail() && secondFile.fail()) // if second file ended first
{
    while(getline(firstFile, line1))
    {
        thirdFile<< line1 << endl;
    }
}
NathanOliver 429 Veteran Poster Featured Poster

You need a semi colon after the closing brace on line 25

NathanOliver 429 Veteran Poster Featured Poster

Did you move main outside of the class? If you have post the code you have know.

NathanOliver 429 Veteran Poster Featured Poster

Your main function needs to be outside of your class defenition

NathanOliver 429 Veteran Poster Featured Poster

Well you could make a base class that has a generic function called getList() that would display the list. Then you could derive your differnt kinds of list from that base class. then the foo() function will get passed a pointer to the base class so it can except both sub list. In the foo() function you would then call the getList of the pointed to object

myk45 commented: thanks! +5
NathanOliver 429 Veteran Poster Featured Poster

It is displaying zero because you never pass a value to balance. You have to make a constructor in your child class that will take an int and pass it to the constructor of the parent class. Just because you create an object of a derived class doesn’t mean it will get the values of the base class you declared first.

NathanOliver 429 Veteran Poster Featured Poster

is line 51 displaying 0?

NathanOliver 429 Veteran Poster Featured Poster

You are not reseting count anywhere. After line 16 put count = 0; and see what happenes.

NathanOliver 429 Veteran Poster Featured Poster

I think the issue is comming from how you are sizing the vector. I think you should use this to define the size of the vector in your constructors.

grid.resize(rows);
for (int i = 0; i < rows; i++)
{
    grid[i].resize(cols);
}
NathanOliver 429 Veteran Poster Featured Poster

I have not used dev c++ but I know that in MSVC++ you have to add all of the files that you want compiled into the application into the project.

NathanOliver 429 Veteran Poster Featured Poster

What compiler/IDE are you using? Do you include the files when they are seperate into your project?

NathanOliver 429 Veteran Poster Featured Poster

What do you mean by in the same file? Is all of this code in one file or is it seperate files and they are all in the same project?

NathanOliver 429 Veteran Poster Featured Poster

Are you trying to remove the .cpp file from your project?

NathanOliver 429 Veteran Poster Featured Poster

What seams to be the problem?

NathanOliver 429 Veteran Poster Featured Poster

This is the code from the post I linked to.

#include <iostream>
using namespace std;

int main()
{
    int n = 10, inpt;

    for( int i = 0; i < n; i++ )
        cin >> inpt;

    for( int i = 0; i < n; i++ )
        cout << i << endl;

    return 0;
}

What this does is that it reads in the n number of integers. Then it displays to the console integers in the range 0 -> n-1. The problem says "there are no duplicates in the input and every number to be read is a non-negative value that is less than n's value.". Since there are no duplicates and all numbers are less than n all you need to do is display 0 to n-1.

NathanOliver 429 Veteran Poster Featured Poster

This was alread answered here. It is a trick question.

NathanOliver 429 Veteran Poster Featured Poster

Your loop should look like this

for(int i=0; i < 50; i++)
{
    infile >> list[i];
    cout << list[num];
}

You also dont need to put it in a while loop if you know you are only going to read 50 records. If you dont know how many records you need to read than you wan use a while loop like this.

int i = 0;
while(infile >> list[i])
{
    cout << list[i];
    i++;
}
NathanOliver 429 Veteran Poster Featured Poster

You say Heading is a QString. Why to you have the () after it? Is it a function that returns a QString? What happens if you do QString = theArray[10].Heading()?

NathanOliver 429 Veteran Poster Featured Poster

It is a default parameter. If you do not send anything then it will default to zero but if you pass a value it will get the value passed. To pass the value you would need to have a child constructor like this.

Child(int n) : Parent(n)
{
    cout << num;
}
NathanOliver 429 Veteran Poster Featured Poster

First things first. when you want to check if more than one thing is equall to the same value you have to do

if(x <= 100 && y <= 100 && z <= 100)

Secondly you can only fave one return value in a function. You can not return three things like you are doing.

NathanOliver 429 Veteran Poster Featured Poster

In your system you could have a CR/LF for \n. This would mean you have two charecters to get rid of. An easy way to get arroung this is to take in everything as a string and then convert the string to get what you need. If you want to use ignore than I would suggest using cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'). You do need the <limits> header to use this. What this says is to eat everything in the stream up to the maximum size of the stream untill you hit a \n, then consume the \n.

NathanOliver 429 Veteran Poster Featured Poster

You need to define the size of the 2d array. The way you have it now it should the compiler will make it 2X12 whn you actually need it to be 12X12. I would change it to int prodouct[ROW_SIZE][COLUMN_SIZE];

az-mi51 commented: Thanks! Worked Perfectly +0
NathanOliver 429 Veteran Poster Featured Poster

do you want the class to be templated or just the functions of the class?

NathanOliver 429 Veteran Poster Featured Poster

Have you steped through your code to see what the values are? You could also put in cout statements to print out the values in the function to see if the data is correct.

NathanOliver 429 Veteran Poster Featured Poster

for line 121 you have double shirt_price=0, uniform_cost=0;if(feet <= 6). What is the if doing at the end of the line? This will have an impact on all of your other if statements.

NathanOliver 429 Veteran Poster Featured Poster

You can pass a string to a function that needs a char * by using the c_str() method of the string class. the c_str() function returns a const char * that holds what the string contains. in order for this to work the function you are passing the string into needs to except a const char * instead of a normal char *.

NathanOliver 429 Veteran Poster Featured Poster

line 11 should be

void printout(ifstream& infile, ofstream& outfile ,string names[numRows],double results[numRows][numCol],double average[numRows]);
NathanOliver 429 Veteran Poster Featured Poster

Have you tried splitting the equation up to see if you are getting the values you expected?

NathanOliver 429 Veteran Poster Featured Poster

Are you getting the wrong answer? Are you getting any compiler errors? Have you tried splitting the equation up to see if you are getting the values you expected?

NathanOliver 429 Veteran Poster Featured Poster

It is called a copy constructor because it takes a reference to an object of its own type and creats a new object that is a copy of the object passed into the constructor. take this as an example

std::string foo("foobar");  //uses single argument constructor
std::string bar(foo);  // uses the copy constructor to copy the contents of foo into the new object called bar.
NathanOliver 429 Veteran Poster Featured Poster

All you need to do is use rand to get a random number in the range of your array and then use that number for the index of your array. Something like this:

cout << arr[(rand() % sizeOfArray)];
NathanOliver 429 Veteran Poster Featured Poster

You need a carry variable to store the addition of *Num1 + *Num2. then you need to add carry % 10 to sum. After that you need to dived carry by 10 to get what needs to be carried over to the next addition. You shout get something like this.

int carry = 0;
// in loop
carry = carry + *Num1 + *Num2;
*sum = carry % 10;
carry /= 10;
// in loop
NathanOliver 429 Veteran Poster Featured Poster

Well you can read in each line from the file and see if you find a match

NathanOliver 429 Veteran Poster Featured Poster

Just get rid of the paramater in the function so it looks like this void draw(); and then change the function like this

void Creatures::draw()
{
    al_convert_mask_to_alpha(sprite, al_map_rgb(255,0,255));
    al_draw_bitmap(sprite, getX(), getY(), 0);
}

This will let you use the sprite variable of the class.

NathanOliver 429 Veteran Poster Featured Poster

What is the output that you are getting?

Im pretty sure Walt would tell you this but you should use meaningful titles for your threads. Asking for a specific person to check out your code doesnt really say anything about what is going on.

NathanOliver 429 Veteran Poster Featured Poster

you can also use division and the mod operator to do this. if you want to find out how may 10's you can get out of 87 it would look like this.

int amount = 87;
int tens = amount / 10;  // 87 / 10 = 8
amount = amount % 10;  // 87 % 10 = 7
// now amount holds the reaminder which is 7.
NathanOliver 429 Veteran Poster Featured Poster

Your arrays are not big enough. They should at least have a size of 10.