1,426 Posted Topics

Member Avatar for Freddy Kreuger

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 …

Member Avatar for NathanOliver
0
269
Member Avatar for Glaven
Member Avatar for Builder_1

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.

Member Avatar for NathanOliver
1
497
Member Avatar for mattster
Member Avatar for rayhaneh

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 …

Member Avatar for rayhaneh
0
182
Member Avatar for Learner010
Member Avatar for parvezshahjada
Member Avatar for NathanOliver
0
60
Member Avatar for ADHAMLOVER

Well you can make your own rounding function or you could use [setpercision](http://www.cplusplus.com/reference/iomanip/setprecision/)

Member Avatar for NathanOliver
0
79
Member Avatar for HuePig

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 …

Member Avatar for Banfa
0
357
Member Avatar for JayGarxP

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. …

Member Avatar for Banfa
0
290
Member Avatar for dennis.teye

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.

Member Avatar for Schol-R-LEA
0
180
Member Avatar for Sunil_12
Member Avatar for Vivek_12

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 }

Member Avatar for Vivek_12
0
465
Member Avatar for Nana_29

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

Member Avatar for NathanOliver
-1
179
Member Avatar for bensila4
Member Avatar for BMutev

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/)?

Member Avatar for NathanOliver
0
193
Member Avatar for Jinxx

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 …

Member Avatar for tinstaafl
0
810
Member Avatar for nitin1

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 { …

Member Avatar for NathanOliver
0
362
Member Avatar for skiboy209
Member Avatar for kadyjizz

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

Member Avatar for dhirendra_1
-1
86
Member Avatar for lewashby

`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.

Member Avatar for NathanOliver
0
335
Member Avatar for Tosho
Member Avatar for Zaprzap

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 << …

Member Avatar for NathanOliver
0
254
Member Avatar for Vincent_5

You could use [regular expressions](http://www.cplusplus.com/reference/regex/)

Member Avatar for rubberman
0
220
Member Avatar for lewashby

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 …

Member Avatar for rubberman
0
215
Member Avatar for lewashby

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 …

Member Avatar for lewashby
0
193
Member Avatar for Đăng

Well if you have why Java doesnt then that answers the question. Think of it as "Why does Java not support operator overloading?".

Member Avatar for mike_2000_17
0
429
Member Avatar for Gunjan_1

[Let me google that for you](http://lmgtfy.com/?q=what+is+an+accessor+and+mutator+c%2B%2B)

Member Avatar for NathanOliver
0
60
Member Avatar for maotopapakarabo.ramanaledi

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

Member Avatar for DonnSchwartz
-1
176
Member Avatar for lewashby

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.

Member Avatar for lewashby
0
184
Member Avatar for HuePig

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.

Member Avatar for uonsin
0
425
Member Avatar for Jeroen Mathon

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 …

Member Avatar for JasonHippy
0
568
Member Avatar for Sahilsikka

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.

Member Avatar for DonnSchwartz
0
196
Member Avatar for Saboor880

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?

Member Avatar for Saboor880
0
141
Member Avatar for LucasMNF55
Member Avatar for öahmut0047
Member Avatar for manaog.aaronvici.7

So what seams to be your issue? No one is going to just answer this for you.

Member Avatar for mattster
-1
351
Member Avatar for tentrabyte

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)

Member Avatar for Sarkurd
0
2K
Member Avatar for Saboor880

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 …

Member Avatar for dinad578
0
216
Member Avatar for Suzie999

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.

Member Avatar for Suzie999
0
399
Member Avatar for Sammiboy

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?

Member Avatar for dinad578
0
346
Member Avatar for christinetom
Member Avatar for christinetom
0
276
Member Avatar for sahil_4

You have already asked this question. Just re-posting it will not get people to do your homework for you.

Member Avatar for dinad578
-1
107
Member Avatar for borchu

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 …

Member Avatar for Magnificant
0
3K
Member Avatar for prahesh

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?

Member Avatar for prahesh
0
461
Member Avatar for Saboor880

what is the number 45 21? What should the putput be when you enter 45 21?

Member Avatar for NathanOliver
0
152
Member Avatar for DavidB

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); …

Member Avatar for mike_2000_17
0
348
Member Avatar for myk45

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.

Member Avatar for NathanOliver
0
2K
Member Avatar for Levellous

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.

Member Avatar for Levellous
0
187
Member Avatar for Sarkurd

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() { …

Member Avatar for Sarkurd
0
191

The End.