1,426 Posted Topics
Re: Why on earth would you return a string from this function and not take strings? A `char *` can be converted to a string so you should use strings. Does this code even compile? I'm not sure what compiler ou are using but line 16 should not compile. I'll help … | |
Re: Well you can have the StoneAdventure class hold a vector of rooms and then you can declare room to be a friend of StoneAdventure. | |
| |
Re: @ melissad - What you poseted was not c call at all. `fstream` is from the C++ STL. Not sure if you noticed but your code will run forever or throw an exception for reading outside the bounds of the file or array. There is an error with the inner … | |
Re: Is it not working? It should work but I see you have the code commented out. Why is that? [Here](http://www.cplusplus.com/reference/algorithm/sort/) is a good reference for using sort. | |
Re: What is Error_code? Is the the enum type? Can you post your class? | |
Re: 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 … | |
Re: There is no standard way in c++ to have an `*` replace a character while typing. | |
Re: What compiler are you using? MSVS 2013 does not have an issue with it. Also if you want to intialize number with 4 using braces you would use `int number{4};` | |
Re: Move line 19 to be between lines 6 and 7. | |
Re: You have: bool Expression::IsOperator(char C) { if(C == '+' || C == '-' || C == '*' || C == '/' || C == 'sqrt' || C == 'log' || C == 'abs' || C == '~') { return true; } else { return false; } } Which makes no … | |
Re: That means the the Polynomial class is going to have an array of terms the represent the polynomial. | |
Re: Whats is `sqrt` in `modifiedExpr.replace(modifiedExpr.find(sqrt),sqrt.length(),"#");`? Is it a string? You should be able to do: string sqrt = "sqrt"; size_t pos = 0; while((pos = modifiedExpr.find(sqrt, pos)) != std::string::npos) { modifiedExpr.replace(pos, sqrt.size(), "#") } | |
Re: `modifiedExpr = originalExpr;` needs to be moved outside the loop. The way you have it now is every time the loop is executed `modifiedExpr` becomes the original again erasing what you just did. ![]() | |
Re: When I read an unknown amount of data from a file I will use the following std::vector<int> data; ifstream fin("sampleData.txt"); int temp; // used to store the data from the file temporarily //use >> operator to control the loop so you end on the last good read while (fin >> … | |
Re: I take you have something like `"x + 5"` and you want a function that searches the expression for the variable and replaces it with a number. To do that you can use this: // make var_ a string to handle variables like "xx", "someval" instantiateVariable(string startingExpr, string var_, int … ![]() | |
Re: Well if you have never used C++ you really should learn how to use it before you try to use it. Otherwise how do you know how to start coding the project. Have you programmed in any other languages? What is the project that you need to get done? Does … | |
Re: Go to Project -> Add Class. That will create a new class and bring up the class wizzard. | |
Re: Well `<<` is the shift bits to the left operator. Since the default value for `FOO_ENUM` is 0 you get: unsigned char sideFilter1 = 1 << FOO_ENUM; =unsigned char sideFilter1 = 1 << 0; =unsigned char sideFilter1 = 1; since 1 left shift 0 is still 1. Line 4 is … | |
Re: What kind of project are you using? Is it a standard win32 console app or are you using something differently? ![]() | |
Re: Are you trying to enter a name like "Nathan Oliver"? if so you need to use [getline()](http://www.cplusplus.com/reference/string/string/getline/) and not [>>](http://www.cplusplus.com/reference/istream/istream/operator%3E%3E/). Don't forget to [flush the input stream](http://www.daniweb.com/software-development/cpp/threads/90228/flushing-the-input-stream) when mixing `getline()` and `>>` | |
Re: Line 6: should be using a string not an int. `string nap;` Line 10: get rid of the string decleration. `if (nap == "hétfő")` That should clear up some of your errors. | |
Re: Dido. C++ support so many different programing paradimes that can be related to so many different languages. | |
Re: `string` and `stringstream` need to be qualified with `std::` or you need to put `using namespace std;` in your code after you includes. | |
Re: The way I have done it is like: size_t pos = 0; int counter = 0; // loop untill substrng is not found. while ((pos = strng.find(subStrng, pos)) != std::string::npos) { counter++; pos++; // increment pos so we dont duplicate the last search. } I am writing this from memory … | |
Re: [Here you go](http://stackoverflow.com/questions/895827/what-is-the-difference-between-tmain-and-main-in-c). personally unless I need or want to support command line arguments I just use `int main()` | |
Re: Try p = make_pair(112,"one-one-two"); | |
Re: Okay. And you resurected an 8 month old thread becuase...? | |
Re: Line 35 should use rowSize not colSize. This is because you are stepping through each row and deleting all of the columns. | |
Re: I bet you need to clear the stream after the first while loop. Add `cin.clear()` in between the two while loops. | |
Re: I would suggest that when the program starts you read in all of the data in the file and load it into an collection of "Movie Records". Then you can search that collection for the records you want. | |
Re: Generally speaking read and write are used to read and write binary data in files. Normally that goes hand in hand with [serialization](http://www.parashift.com/c++-faq/serialization.html). | |
Re: Something like this would work vector<string> doc; vector<string> skipWords; // fill doc and skipWords from there files. When doing so convert each word to lower case. Remove any puctuation as well. //c++11 for(auto i : skipWords) doc.erase(remove(doc.begin(), doc.end(), i), vec.end()); | |
Re: As an FYI prerequisite programing classes are very important. Everything you do in higher level programing classes builds off of them. | |
Re: Change `props.emplace(std::pair<string,string>(tokena,tokenb));` to `props.insert(std::pair<string,string>(tokena,tokenb));` | |
Re: Depending on the compiler you are using you might have to have everything in the header file instead of splitting it up like a normal class. I would put everything into the header file and see if that fixes the error. Also on line 15 in the cpp file you … | |
Re: do { your_homework(); } while (in_school) | |
Re: Line 6 in you .cpp is `Nvector::Nvector(int Size) : velicina(Size);` it should be `Nvector::Nvector(int Size) : velicina(Size)` | |
Re: No doing a print screen will remove the mouse icon. You could always draw on the picture though to show where the mouse was when you took the print screen. I do agree with triumphost that you really need to post a picture of what is happening. | |
Re: If the files were not part of a previous project then you need to create a new blank project and then add the files to it. | |
Re: It looks like that is how your instructor wants this done. Why he would want it like this I have no idea. IMHO he should be cited for endangering the education of a student. You could do this with a class but since you functions need to have access to … | |
Re: Why not use an enum class? In C++ it is possible to create real enum types that are neither implicitly convertible to int and that neither have enumerator values of type int, but of the enum type itself, thus preserving type safety. They are declared with enum class (or enum … | |
Re: Do you actuall have a slot column in the database? if so you can use select min(slot) from inventory where item_id is null I'm not quite sure if that is correct for MySQl since I use Oracle PL/SQL but that should be the gist of it. | |
Re: the OP doesnt have any code to pause between the output and the window closing so I would guess that was the issue. | |
Re: Since you are dealing with strings shouldn't `ostream_iterator<int> output(cout," ");` be `ostream_iterator<string> output(cout," ");`? | |
Re: You can use [Code::Blocks](http://www.codeblocks.org/), [Visual Studio Express](http://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx) or a host of [others](http://lmgtfy.com/?q=free+c%2B%2B+compilers). | |
Re: What is your definition of "not working"? | |
Re: Don't use that code. That code is terrible. What are you trying to do? Oh yeah did I mention DON'T USE THAT CODE. |
The End.