1,426 Posted Topics

Member Avatar for super-duper

Well if you need dynamic c-string arrays I would suggest using string from the STL. as far as an a array of structures thats pretty simole too. you can use a hard coded array or you can use one of the containers avalible in the STL. In this case a …

Member Avatar for super-duper
0
182
Member Avatar for onako

if you have a vector of floats you might want to use the for_each function in the algorithms header.

Member Avatar for NathanOliver
0
80
Member Avatar for cogitoergosum18

you have your code like this [code=c++] int firstNo;// first number is stored here int secondNo, int resultAdd,// variable for result when first number and second number are added int resultSub,// variable for result when first number and second number are subtracted int resultMult,// variable for result when first number …

Member Avatar for cogitoergosum18
0
232
Member Avatar for darkmeyi0319

What compiler are you using? also the way to define the standard headers is to not include a .h after it. [code=c++] #include <iostream> #include <ctime> #include <string> #include <vector> //... [/code]

Member Avatar for darkmeyi0319
0
145
Member Avatar for indigo.8

well if you want to convert a char to an int you have to do this [code=c++] char temp = '2'; int number = temp - '0'; // number is now 2 // if you do this int number = temp; // number is now 50 [/code]

Member Avatar for indigo.8
0
5K
Member Avatar for y2kshane

[URL="http://www.cprogramming.com/tutorial/cpreprocessor.html"]macros[/URL]

Member Avatar for NathanOliver
0
62
Member Avatar for frogboy77

you can always use the next_permutation function located in <algorithm>. As mike said you will need to break up then number into each digit and put them into some kind of container. Vectors work well for this. then you will need to sort the container to have the smallest digit …

Member Avatar for frogboy77
0
84
Member Avatar for dadam88

Does this program run correctly? Lines 57-75 looks like it is an infinite loop. On lines 97 and 98 you have 2 return statements. You can only return one thing from a function. This is not to say you cant have a multiple returns in a function, you just cant …

Member Avatar for dadam88
0
98
Member Avatar for mrkaran

Do you really need to use strcmp? String's have a built in operator == that you can use for comparison. [code=c++] std::string foo = "foo"; std::string bar = "bar"; if (foo == bar) std::cout << "foo and bar are equal."; else std::cout << "foo and bar are not equal.": [/code] …

Member Avatar for NathanOliver
0
102
Member Avatar for Nandu Das

@ Nandu Das The purpose of this forum is to help not to just give you the code. If you are having a particular problem with this problem then state what that is and we can help. With that said you can do this very simply. you will need three …

Member Avatar for NathanOliver
0
197
Member Avatar for Aia

I am sad that he will not be with us anymore. He had given me some wonderful advice and wasn't afraid to call me out if what I said was incorrect. He will be missed

Member Avatar for sureronald
9
625
Member Avatar for garea

the problem is the chicken and the egg paradox. what comes first in your code A or B?. if A is first and A uses B then the compiler goes to B to find out what B is but B has A in it and A isn't finished so it …

Member Avatar for rodc
0
815
Member Avatar for mark88211

@ sourabhtripathi [icode]*p2--;[/icode] does not change the memory address. it actually is subtracting 1 from the value stored at p2. also you don't have the values initialized to anything. here is a link for you. [url]http://www.cplusplus.com/doc/tutorial/pointers/[/url]

Member Avatar for bagi.padhu
0
425
Member Avatar for intelfx

@firstPerson The link you provided states that both list must be sorted by a strict weak sorting method. So the OP would have to call [icode]sort()[/icode] on his list first before he sends them to [icode]std::set_difference[/icode]

Member Avatar for intelfx
0
3K
Member Avatar for Silvershaft

In your build log it shows its compiling 2 playerhandeler.cpp and 2 main.cpp. maybe something going on there.

Member Avatar for Hektzu
0
212
Member Avatar for dhruv_arora

What happens if you do this? [code=c++] ofstream f1("s.dat", ios::binary); //... output to file here f1.close(); [/code]

Member Avatar for p@rse
0
133
Member Avatar for p@rse

Why are you using c functions in c++ code? Also you are mixing strings and char arrays. Is there a reason for that? Lastly you should not use eof() for you while loop. Just use your getline staement for your while condition.

Member Avatar for p@rse
0
107
Member Avatar for fenerista

How is your matrix defined? If it is a class than you can put it into a [icode]std::list[/icode]. Also you can add a get funtion to your class that will return the element you are looking for. [code=c++] class Matrix { //... int GetData(int row, int col); // returns the …

Member Avatar for fenerista
0
130
Member Avatar for SacredFootball
Member Avatar for Andreas5

I looked at the book and it looks like since there are multiple keys that are the same the author decided to have each rule be in a vector. That way you have one key "adjective" and then a vector that has 3 different rules in it. This way one …

Member Avatar for Ancient Dragon
0
143
Member Avatar for SnakeJam

The reason this is happening is there is a newline left in the buffer from line 145. when you call getline() in you accessUNIT() function it reads in the newline and that's all. To fix it put [icode]cin.get();[/icode] on line 146. Try reading [URL="http://www.daniweb.com/forums/thread90228.html"]this[/URL] for more information.

Member Avatar for SnakeJam
0
122
Member Avatar for scholar

Do you have a tree already or do you need one? Also what type of data does the file have? What I mean by that is, is child1 a string or something else you are just calling it child1?

Member Avatar for NathanOliver
0
134
Member Avatar for tundra010

Lines 21 and 22 are wrong. They should be [code=c++] hasSetPages = new bool; hasSetColor = new bool; [/code]

Member Avatar for thelamb
0
114
Member Avatar for avarionist

I would re write your function like this [code=c++] string backwards(string input) { string temp; for (size_t i = input.size() - 1; i >= 0; i--) temp += input[i]; return temp; } // then in you main function cout<<"Input backwards is : " << backwards(input); [/code] FYI size_t is the …

Member Avatar for avarionist
0
243
Member Avatar for DelilahDemented

What exactly do you want to do if there is a non number in the string? that will determine what you need to do.

Member Avatar for DelilahDemented
0
237
Member Avatar for YasaminKh

you can use string streams to do this but you will to be able to put that number into an int. An int only holds integer values. You will need to put it into a double or float data type. [code=c++] #include <sstream> // you will need this to use …

Member Avatar for NathanOliver
0
139
Member Avatar for dansnyderECE

if you use strings' [icode]find_first_of()[/icode] to locate the < you can store the position of the < in a variable and then call [icode]find_first_of()[/icode] for > starting at position + 1. [code=c++] size_t firstPos = 0, secondPos; string temp = "4ab030 <__do_global_ctors_aux>"; string sub; if ((firstPos = temp.find_first_of("<", firstPos)) != …

Member Avatar for NathanOliver
0
125
Member Avatar for madzam

I think the problem is coming from the way you are using your if...else statements. On line 54 you check to see if the area is greater than 750 and if it is you add your base_cost with 750 and store it into total_cost but if its not you don't …

Member Avatar for nbaztec
0
115
Member Avatar for Valaraukar

The way you have declared the templated function is wrong. if your function is a void function then instead of this [code=c++] template <class T> REGISTER_BUILDER<T>(Builder, T, "RecoBuild", ViewType::kAll3DBits);//(name, type, purpose, view) [/code] Try this [code=c++] template<class T> void REGISTER_BUILDER(Builder, T, "RecoBuild", ViewType::kAll3DBits);//(name, type, purpose, view) [/code] When you template …

Member Avatar for Valaraukar
0
202
Member Avatar for respondto

If you have long lines that go off the screen just separate it onto multiple lines [code=c++] for (thisReallyLongVariableName = anotherVeryLongName; thisReallyLongVariableName < somethingRealyComplex; thisReallyLongVariableName += moreOfTheSameStuff { //... [/code]

Member Avatar for NathanOliver
0
2K
Member Avatar for emcyroyale

I believe this is because your function names and your variable names are the same. try changing all of your function names to start with a capital letter [code=c++] double Radius(double x, double y, double xs, double ys); double Diameter(double x); double Circumference(double x); double Area(double x); // instead of …

Member Avatar for NathanOliver
0
201
Member Avatar for deez2183
Member Avatar for aj79

you could always write your own dynamic array class and use that to store the input into it then add up all of the digits. I'm not sure if that would be considered cheating since it uses the same approach as the STL.

Member Avatar for aj79
0
215
Member Avatar for angelrapunzel

First void main is a big no no. main should return an int and only an int. Second [icode]<iostream.h>[/icode] is depreciated and should not be used as well. You should use [icode]<iostream>[/icode]. Lastly please use indentation in you code. It makes it much easier to read.

Member Avatar for NathanOliver
0
111
Member Avatar for daviddoria

Pretty nice page from what I have read so far. Good job. You might want to add the output created from the program just to be a little extra helpful.

Member Avatar for Bench
4
151
Member Avatar for YasaminKh

You can use string streams to convert a string into a number. [URL="http://programmingexamples.net/index.php?title=CPP/StringStream"]this is from dave's new wiki[/URL]

Member Avatar for nbaztec
0
185
Member Avatar for NathanOliver

He all I am currently working a on a problem to convert the entire contents of an STL container into a string. For example if I had this: [code=c++] int foo[] = {1, 2, 3, 4, 5}; vector<int> bar(foo, foo + 5); [/code] I would like to convert [icode]bar[/icode] into …

Member Avatar for Bench
0
127
Member Avatar for KAY111

Try wrapping the for loop in parentheses. I also split the macro into multiple lines. [code=c++] #define forallXNodes(u,G) \ (for(arc *bfs_ee=(G.getSource())->firstOutArc(),arc *bfs_stopA=\ (G.getSource())->lastOutArc(),u=bfs_ee->head(); bfs_ee <= bfs_stopA;u =\ (++bfs_ee)->head())) [/code]

Member Avatar for KAY111
0
1K
Member Avatar for bubacke

@ OP If your compiler evaluates both functions in this code than I suggest you get a new one. [code=c++] #include <iostream> using std::cout; bool returnTrue ( ) { cout << "ret TRUE\n"; return true; } bool returnFalse( ) { cout << "ret FALSE\n"; return false; } int main() { …

Member Avatar for bubacke
0
132
Member Avatar for YasaminKh
Member Avatar for YasaminKh
0
127
Member Avatar for uhmyeah
Member Avatar for NathanOliver
0
171
Member Avatar for mnmw

Your program starts to fall apart with numbers larger than 15. You might want to rethink your algorithm.

Member Avatar for dohpaz42
-2
191
Member Avatar for KAY111

what would happen if you change you include section to look like this [code=c++] #include <iostream> #include <cstdlib> #include <stdio.h> #include <assert.h> using namespace std; [/code]

Member Avatar for KAY111
0
15K
Member Avatar for Griff0527

Making a 2d array for this is pretty strait forward. Because you don't know how many duplicates are in the array you would need to have an array like [code=c++] int ** twoDarray = new int*[size]; for (i = 0; i < size; i++) towDarray[i] = new int[1]; [/code] Now …

Member Avatar for NathanOliver
0
1K
Member Avatar for Hawkpath

Sorry this is a little of topic but does Ein have anything to add to the conversation Edward?

Member Avatar for NathanOliver
0
139
Member Avatar for fandango

Just start off with a blank vector and push the objects on. [code=c++] class Foo { // ... } int main() { vector<Foo> container; for (int i = 0; i < 10; i++) { container.push_back(Foo()); } } [/code]

Member Avatar for Radical Edward
0
222
Member Avatar for Dimitar
Member Avatar for avarionist

I think what you are trying to do is input a word and see if any part of that word matches what you have in a text file. now do you want only sequential letters to make the work or can it be any combination of letters in the inputted …

Member Avatar for NathanOliver
0
376
Member Avatar for aliyami90

@ VirtualAssit Its nice to see that you are trying to help but please use code tags. Secondly the code that you posted is non standard. void main() is a big no no. main should only return an int according to the c++ standard. The function clrscr() you used is …

Member Avatar for NathanOliver
0
829
Member Avatar for Grusky

well you have a doubly linked list so in reverse start at the last node and then traverse your way backwards by calling previous.

Member Avatar for daviddoria
0
137

The End.