NathanOliver 429 Veteran Poster Featured Poster

fclose() is declared as int fclose ( FILE * stream );. As you can see it only takes one FILE*. So the answer to your question is no.

NathanOliver 429 Veteran Poster Featured Poster

And you have done what so far? We do not do your homework for you on this site.

NathanOliver 429 Veteran Poster Featured Poster

Here is a listing of escape codes:

\n newline
\r carriage return
\t tab
\v vertical tab
\b backspace
\f form feed (page feed)
\a alert (beep)
\' single quote (')
\" double quote (")
\? question mark (?)
\ backslash ()

Ahmad Imran commented: so just a beepo +0
NathanOliver 429 Veteran Poster Featured Poster

Is your student class also a linked list?

senait.kifle.127 commented: Yes it is. +0
NathanOliver 429 Veteran Poster Featured Poster

I would think line 8 needs to be:

TableMenuShortCuts[TableMenuShortCuts.size()-1].key=(c[c.size()-1])[0];
cambalinho commented: thanks +3
NathanOliver 429 Veteran Poster Featured Poster

What did you plug in for the missing values and what does your for loop look like now? Remember when you are doing the summation that if the number is divisible by 15 you add 15, if it is divisible by 5 you add 5, if it is divisible by 3 then you add 3, otherwise you add only 1. when I run my version of the program for 5 to 15 I get 39.

NathanOliver 429 Veteran Poster Featured Poster

@cambalinho The reason you are gettting that error is std::string.c_str() returns a char* to the c-string the string contains. A char and a char* are not the same thing. If you want just the first character from the c-string then you can use:

TableMenuShortCuts[TableMenuShortCuts.size()-1].key=(j.c_str())[0];

// or

TableMenuShortCuts[TableMenuShortCuts.size()-1].key=*(j.c_str());
cambalinho commented: thanks +0
NathanOliver 429 Veteran Poster Featured Poster
x<=i<=y

Is not valid c++. If you need to loop between all number in x and y then you can use:

for (int i = x; i <= y; i++)

Wich is translated to: start with i equall to x and loop while i is less than or equall to y increment i by one with every iteration.

NathanOliver 429 Veteran Poster Featured Poster

when something is evenly divisible by a number the modulo is 0.

15 / 3 = 5
15 % 3 = 0

Knowing this you can write the following code to see if something is divisble by a number:

if(someNUmber % 3 == 0)
    the number is divisble by 3
if(someNumber % 5 == 0)
    the number is divisble by 3
if(someNumber % 3 == 0 && someNumber % 5 == 0)
    the number is divisble by 3 and 5
NathanOliver 429 Veteran Poster Featured Poster

You can change your function to the following to take into account the filename.

bool operator() (finfo i, finfo j)
{
    if(i.fsize == j.fsize)
        return i.filename > j.file
    return (i.fsize > j.fsize)
}
NathanOliver 429 Veteran Poster Featured Poster

-O0 will give you zero optimization and can't remember where I was told this since it was a few years ago but that will definitely cause your code to be very slow. I would recommend using -Og which is:

Optimize debugging experience. -Og enables optimizations that do not interfere with debugging. It should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation and a good debugging experience.

That should give you the best of both worlds.

source: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

NathanOliver 429 Veteran Poster Featured Poster

Line 270: virtual ~Deck():

Notice anything wrong with that?

Lilgenski16 commented: That isnt an error, so there is not anything wrong with it, the : is correct instead of the ; +0
NathanOliver 429 Veteran Poster Featured Poster

line 5: void print(string *ar[]) which becomes
line 5: void print(string **)

line 23 print(&s) which becomes
line 23 print(s)

Since the name of an array is the address of the array. In your code if you put before line 23

cout << s;
cout << &s;

You should get the same value. If you want to get an array in your print function I would just write:

void print(const string * arr, int size)
{
    for (int i = 0; i < size; i++)
        cout << arr[i];
}
NathanOliver 429 Veteran Poster Featured Poster

There are two main ways to delete a list that I know. You can use recursion or you can iterate.

// recursion
void delete(listNode node)
{
    if (node.next != nullptr)
        delete(node.next);
    delete node;
}

// iteration
void delete(listNode node)
{
    listNode temp;
    while (node != nullptr)
    {
        temp = node.next;
        delete node;
        node = temp;
    }
}
NathanOliver 429 Veteran Poster Featured Poster
B& operator=(const B& b)            // Copy Assignment
{
    if (&b != this) // you should always do this so you dont do a self assignment
    {
        A::operator=(b) // call A copy assignment
        i2=b.i2;
    }
    return *this;
}
NathanOliver 429 Veteran Poster Featured Poster

I dont think so. Maybe you should read the Rules.

NathanOliver 429 Veteran Poster Featured Poster

Step 1: Write a problem statement for what you want to do
Step 2: Write an outline, if it is complex
Step 3: Write up a section in pseudo-code (English instructions)
Step 4: Write the section in the programing language of your choice
Step 5: Compile the program.
Step 6: Run your program and see if it makes the computer do what you wanted.
Step 7: If not, fix the program, and compile and go back to step 5. Otherwiae release / turn in your program.

NathanOliver 429 Veteran Poster Featured Poster

This details why this can't be done. There is a hack here that you can do to get around this but it is not microsoft approved.

NathanOliver 429 Veteran Poster Featured Poster

I would use the modulo operator (%) and division for this. Modulo gives you the remainder of integer division so 100 % 10 = 0. So if 100 % 10 = 0 then you need to get rid of the rightmost 0 by division. Divsion by 10 will do that. Put it together and you need a while loop that checks if the value modulo 10 is 0 and then in the body of the loop you need to trim off that zero using division by 10.

NathanOliver 429 Veteran Poster Featured Poster

What problem are you actually having? Do you know how to find if two circles on a plane intersect? I don't think you will find anyone on here that is willing to do your work for you. To find out if two circles intersect you can see if the difference of their radii is less then or equal to the distance the circles are apart. That would be:

R1 - R0 <= sqrt((x1-x0)^2 + (y1-y0)^2) 

You could also square both side to not have a call to sqrt and it would be:

(R1-R0)^2 <= (x1-x0)^2 + (y1-y0)^2
NathanOliver 429 Veteran Poster Featured Poster

Show we what code you used for that. Did you remove the line inFile >> number; from inside the while lop as that will cause a double read.

NathanOliver 429 Veteran Poster Featured Poster

Give this article a read.

NathanOliver 429 Veteran Poster Featured Poster

while (!inFile.eof()) is never the way you want to read from the file. When reading the last line of the file the EOF flag does not get sent until it tries to read past the last line so while (!inFile.eof()) will actually read all lines in the file plus one. You should use a read operation to control the loop since once the read fails it stops the loop. Since you use inFile >> number; in your while loop you can rewrite it as the following:

while (inFile >> number)
{
    total += number;
    count++;
    cout << number << endl;
}
NathanOliver 429 Veteran Poster Featured Poster

This could be done very simply with the strings [] operator:

int main()
{
    std::string line;
    std::cout << "Please enter you string: ";
    getline(std::cin, line);

    // loop through each letter and add 2 to it while displayng it
    for(std::string::size_type i = 0; i < line.size(); ++i)
    {
        std::cout << char(line[i] + 2);
    }

    std::cin.get(); // use this to pause system.  not system("pause")
    return 0;
}
NathanOliver 429 Veteran Poster Featured Poster

I think you missed the most important part of the assignment.

You are required to write a program...

NathanOliver 429 Veteran Poster Featured Poster

What is the problem you are having? Taking some else's broken code and trying to use might not be the best approach.

NathanOliver 429 Veteran Poster Featured Poster

You should be using a different string to read from the file. You are overwriting schools with what is in the file. This:

while(getline(campuses,schools, '\n'))
{
    schoolVector.push_back(schools);
}

Should be

string temp;
while(getline(campuses,temp, '\n'))
{
    schoolVector.push_back(temp);
}

As far as problem 2 goes what you need to do is create a bool variable and set it to false. Then as you are going through the vector if you find the school then you should set the variable to true. After the loop then check the variable and print accordingly.

JasonHippy commented: Nice spot, I missed that! +9
NathanOliver 429 Veteran Poster Featured Poster

That's because you have a newline floating in the input buffer from line 32. To get rid of the newline in the buffer you can just put cin.get() after line 32. That should at least get you into the queue1 function.

Builder_1 commented: thanks alot man....really grateful for your assistance bro +1
NathanOliver 429 Veteran Poster Featured Poster

It is really weird that the lines with the text at the end don't have a coma where the lines with a number do. Since you do not need the extra column you should be able to get away with using a stringstream to split the columns. I would do something like the following. I am not sure how you are storing the information from the file in your program so in my example each part will just be a string stored in a vector. Each vector will be stored in a vector of vectors.

std::string line;
std::vector<std::vector<std::string>> lines;
stringstream ss;
ifstream fin("filename.csv");

while (getline(fin, line))
{
    std::string temp;
    std::vector<std::string> parts;
    // load line in stringstream
    ss << line;
    // we need for columns only so use a loop 4 times
    for (int i = 0; i < 4; i++)
    {
        getline(ss, temp, ',');
        parts.push_back(temp);
    }
    lines.push_back(parts);
    ss.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
    ss.clear();
}
NathanOliver 429 Veteran Poster Featured Poster

Well first off you need to write a function to compute x!. ! means factorial in math. Once you compute the factorial of the number then you need to go through each digit of the number and get the minimum digit. To do that you use the following algorithm:

min = 9;
number = factorial(x)
do
    digit = number % 10 <- this get the last digit of the number
    if digit is less than min and digit does not equal 0
        set min to equal digit
    number = number / 10 <- this drops the last digit off of the number
while number does not equal 0

and at last "cout" 886= 384

I have no idea what this means so i cant help you with that.

I would also like to point out that you have the wrong minimum for all of your answers 10! would be 2 and 11! and 12! would be 1.

NathanOliver 429 Veteran Poster Featured Poster

ddnabe that price is a little steep. Since he is new couldn't you cut him some slack and only charge $99,999.95?

NathanOliver 429 Veteran Poster Featured Poster

Yes. That function returns the largest of x, y, and z.

NathanOliver 429 Veteran Poster Featured Poster

Here is a better example for you.

//...

std::string type;
int count;
int candyTotal = 0;
int costumesTotal = 0;
int decorationsTotal = 0;

std::ifstream fin("myfile.txt");  // open file

while we read in what type of item we have keep looping through the file
while(std::getline(fin, type))
{
    fin >> count;
    if (type == "candy")
        candyTotal += count;
    else if (type == "costumes")
        costumesTotal += count;
    else if (type == "decorations")
        decorationsTotal += count;

    // ignore '\n' left in buffer from `>>`
    fin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}

//...
Jinxx commented: Thanks for your help! +0
NathanOliver 429 Veteran Poster Featured Poster

Okay. Why dont you do that then?

NathanOliver 429 Veteran Poster Featured Poster

So what do you have so far? No one is going to do you homeworkfor you.

NathanOliver 429 Veteran Poster Featured Poster

This is not a critique of your code but a way to make it look a little better. In your SplitBySpace function you can make it a lot simpler by using stringstreams.

vector<string> SplitBySpace(const string & s)
{
    stringstream ss;
    string temp;
    // load s into the stringstream
    ss << s;
    vector<string> ret;
    // while there a parts in ss load them into ret
    while(ss >> temp)
    {
        ret.push_back(temp);
        temp.clear();
    }
    return ret;
}

Using a stringstream takes advantage of the fact that white space is ignored just like using cin. I do have to agree with Mike that your code is very well done for a begginer. If only more people could put as much effort into there code when starting out.

NathanOliver 429 Veteran Poster Featured Poster
Rectangle operator+ (const Rectangle& p1)
{
    return Rectangle(width + p1.width, height + p1.height);
}

Breaking down this function we see the return type is a Rectangle. In the parameter list we have const Rectangle& which means give me a constant Rectangle reference. & means reference and a reference is basically a pointer but you use it like a regular variable. passing a reference of an object to functions is cheaper then passing the function by value so that is why it is done. const is in there so that you can pass a constant or non constant variable. if const wasn't there you would not be able to pass constant variables to the function.

In the function width is the width of the object that is having plus called on where as p1.width is the with of the rectangle that was passed to +.

ddanbe commented: Good explanation +15
NathanOliver 429 Veteran Poster Featured Poster
NathanOliver 429 Veteran Poster Featured Poster
class A 
{
public:
    int x;
protected:
    int y;
private:
    int z;
};

class B : public A
{
    // x is public
    // y is protected
    // z is not accessible from B
};

class C : protected A
{
    // x is protected
    // y is protected
    // z is not accessible from C
};

class D : private A
{
    // x is private
    // y is private
    // z is not accessible from D
};
NathanOliver 429 Veteran Poster Featured Poster

@ dinad578 do not give answers to homework questions when the OP made no attempt at all to solve the problem.

NathanOliver 429 Veteran Poster Featured Poster

What are you expecting it to do?

NathanOliver 429 Veteran Poster Featured Poster

Suzie I did some checking and it looks like load_gif_external() uses ImageMagick or GraphicsMagick's external tools. save_gif_external() does not say that it does but you would think the load and save use the same mechanics.

NathanOliver 429 Veteran Poster Featured Poster

You have a reference member (highscore) in LavaLand and that needs to be initialized upon creation. Either remove the reference or change the constructor to take in a value to initialize highscore.

NathanOliver 429 Veteran Poster Featured Poster

Look at your constructor versus my constructor.

NathanOliver 429 Veteran Poster Featured Poster

If you want LavaLand to have a default generated constructor then you need to get rid line 8 in LavaLand.h. You could also just change line 8 to LavaLand() {}; to make a default constructor yourself.

NathanOliver 429 Veteran Poster Featured Poster

Why is a captian a singleton? Are there not multiple captains in the world? If you want to make a singleton then you need to follow the correct syntax. Here is an example of a singleton:

class Singleton
{
public:
    // this is a lazy evaluated singleton
    Singleton GetInstance()
    {
        static Singleton instance;
        return instance;
    }
private:
    Singleton() {};  // code for constructor goes here
    // make sure these are here to stop the object from being copied
    Singleton(const Singleton &);
    void operator=(const Singleton &);
}
NathanOliver 429 Veteran Poster Featured Poster

Is it not working? It should work but I see you have the code commented out. Why is that? Here is a good reference for using sort.

NathanOliver 429 Veteran Poster Featured Poster

That's not going to happen. This is not a website where you post your problem and you get an answer. This is a place where you come to with questions about an answer and we will help you with it. You get what you put in. Putting in nothing gets you nothing.

Ivzirnalsradeys commented: i understand and sory +0
NathanOliver 429 Veteran Poster Featured Poster

Well that is pretty easy to do. You need to calls two >> and one call to ignore to eat the rest of the line. The folwwing is psuedo code:

column1, column2
// use ifstream for file read operations
ifstream file(some data file);
// since the first read operation in a line is >> use that for the loop control
while (file >> column1)
{
    file >> column2
    file ignore rest of line
    add column1 and column2 to some sort of container.
}

You can read here on how to ignore the rest of the line in the file.

rehan_5 commented: Thanks Alot.. +0
NathanOliver 429 Veteran Poster Featured Poster

You are running Visual Studio 2012 which is version 11. version 11 has little to no c++11 support. You need to go to version 2013 update 3 to get te best support that Microsoft offers.