1,426 Posted Topics
Re: 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 … | |
Re: Post the code that you have now. | |
Re: 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. | |
Re: Well first off you need to write a function to compute `x!`. `!` means [factorial](http://en.wikipedia.org/wiki/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 … | |
Re: Yes. That function returns the largest of x, y, and z. | |
Re: Since it was assigned to you maybe you should write it. | |
Re: Well you can make your own rounding function or you could use [setpercision](http://www.cplusplus.com/reference/iomanip/setprecision/) | |
Re: It seams to me the blackboard needs to store the message along with the user who posted it. Then the subscribers will hold a list of the users they are subscribing to. When a new message is added all subscribers would get notified of the user that posted and only … | |
Re: You are trashing our memory in your `Sport::Add()` function. You are adding a local variable to an array of pointers on line 222 which I believe is causing your issues. Have you ever thought about using [vectors](http://www.cplusplus.com/reference/vector/vector/) instead of arrays so you don't have to worry about the memory management. … | |
Re: A) You are in the wrong formum >Write an interactive program in C B) You didn't read the [rules](https://www.daniweb.com/community/rules) or you ignored them. | |
Re: What are `empid_` and `phone_`? Are they strings? If not they need to be. | |
Re: string's operator `==` can take a `string` and a `char` so all you have to do is: i=0; while(i<23){ c = char(i) //convert c which is a character into string if (S[i] == c) // do something here } | |
Re: ddnabe that price is a little steep. Since he is new couldn't you cut him some slack and only charge $99,999.95? | |
Re: So what do you have so far? What are you stuck on. | |
Re: What exactly is the purpose of this? You are just trying to make a symbol table? Have you thought about using a [map](http://www.cplusplus.com/reference/map/map/)? | |
Re: If you know what all of the types are then youcould do something like the folowing while getting records from the file if type == candy add amount to candy total else if type == costumes add amount to costumes total else if type == decorations add amount to decorations … | |
Re: you have to use forward declarations and pointers. A.h #ifndef A_H #define A_H class B; class A { private: B* bclass; public: //... }; #endif A.cpp #included "A.h" #included "B.h" // code for class a goes here. B.h #ifndef B_H #define B_H #included "A.h" class B : public A { … | |
Re: What is the code you added that broke it? | |
Re: So what do you have so far? No one is going to do you homeworkfor you. | |
Re: `ifstream` is a class that is used for reading files. `file_in` is an object of the class `ifstream` and it is used in the program to read from a file. [Here](http://www.cplusplus.com/reference/fstream/ifstream/) is a good reference for what you dan do with an `ifstream` object. | |
Re: Okay. Why dont you do that then? | |
Re: 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](http://www.cplusplus.com/reference/sstream/stringstream/). vector<string> SplitBySpace(const string & s) { stringstream ss; string temp; // load s into the stringstream ss << … | |
Re: You could use [regular expressions](http://www.cplusplus.com/reference/regex/) | |
Re: What book are you using if I might ask. It might just be that you need a better book. Book* pA = new Book("Aardvark", "Be an Aardvark on pennies a day"); That piece of code says make a variable called pA that is a pointer to a book object and … | |
Re: 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 … | |
Re: Well if you have why Java doesnt then that answers the question. Think of it as "Why does Java not support operator overloading?". | |
Re: [Let me google that for you](http://lmgtfy.com/?q=what+is+an+accessor+and+mutator+c%2B%2B) | |
Re: @ dinad578 do not give answers to homework questions when the OP made no attempt at all to solve the problem. | |
Re: Making things private vs protected deal with what access inherited classes have to members. Public: everything has access to it. Protected: Only acessible from the class or classes dervied from the class. Private: Only accessible from the class. | |
Re: If you want to store an object in a hash map then you need to create a hashing function that will convert the object into a hash value. | |
Re: Did you read [this](http://www.sqlite.org/cintro.html) site? From the looks of it you need to create a connection with `sqlite3_open()` then pass that connection with a sql string to `sqlite3_prepare()` and it will give you a statement. You can use that statement with `sqlite3_step()` to step through each row of the results … | |
Re: AFAIK `int a = 10;` will allow the compiler to directly construct `a` with the value of 10 where as when you split it up the code still has to create `a` and then you have an additional assignment to assign `10` to it. | |
Re: You are missing a `<` in between `"\t"` and `program`. Change line 19 to `cout<<name<<"\t"<<rollno<<"\t"<<program<<endl;` and you should be okay. Now all that's left to do is make your code standard compliant. What compiler are you using? | |
Re: So what seams to be your issue? No one is going to just answer this for you. | |
Re: If you name has a space in it then you need to use `getline()` and not `>>`. You need to make sure that you ["flush" the input stream](https://www.daniweb.com/software-development/cpp/threads/90228/flushing-the-input-stream) if you do a call to `>>` and then use `getline()`(mixing input operations) | |
Re: You are running out of the bounds of the array using `i<=4` in your for loop. `if(arr[i]>(arr[i+1]))` will also run out of bounds when you are at the end of the array. You also don't want the print to be in the loop since it would print every time it … | |
Re: Suzie I did some checking and it looks like [load_gif_external()](http://cimg.sourceforge.net/reference/structcimg__library_1_1CImgList.html#ace7c5fbf383558c31bbf08fd58807f84) 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. | |
Re: So many bad things in that code. `#include<iostream.h>` and `#include<conio.h>` are not standard. `void main()` is not standard as well. `main()` should only ever return an int. `clrscr()` is not portable. Why do you have an array of 10 for 5 values? | |
Re: What does your file data look like? What should it look like after decrypting? | |
Re: You have already asked this question. Just re-posting it will not get people to do your homework for you. | |
Re: If you want to find the second max you need to have 2 max variables. the first will hold the actual max and the second will hold the number that is greatest after that. [code=c++] int max = 0, max2 = 0, grade; cout << "Please enter your numbers (-1 … | |
Re: Why are you not able to use ifstream? If this is c++ code then either fstream or ifstream is what you need to use to read data from a file. Is this supposed to be C code? | |
Re: what is the number 45 21? What should the putput be when you enter 45 21? | |
Re: Have you ever worked with [iterators](http://www.cplusplus.com/reference/iterator/)? Using iterators you could do code like this. typedef vector<double> C1DArray; double sum(C1DArray::iterator it, C1DArray::iterator end) { double sum = 0; while(it++ != end) sum += *it; return sum; } int main() { C1DArray data; for(int i = 0; i < 30; i++) data.push_back(i); … | |
Re: When you open the HTML document in your browser does it show the image? Where is the image located relative to the HTML document? I have not used Qt but doing some basic googling it looks like you might need to use `QTextDocument::loadResource` to added images to the document. | |
Re: 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. | |
Re: 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() { … |
The End.