1,426 Posted Topics
Re: The problem is that `cin.get(response);` is leaving an `'\n'` in the buffer so when you call `cin.get(c);` at the beginning of the loop it pulls in the `'\n'`. Since `'\n'` stops the inner loop it never gets executed and then you are asked to continue again. To fix this you … | |
Re: Compare each element entered by the user to the previous input. If the number is smaller then set it to min. Otherwise keep the min you already have. Since you don't know what min should be on the first entry you either need to set min to the first entry … | |
Re: @Zee Khan - Start a new thread, don't resurrect a 6 year old thread. You should try to see if you can do it first and then if it doesn't work then ask for help with the code you have. | |
Re: Start a new thread and post the code that you have and the problem it is having. | |
Re: I have to add that if you have a C++ 11 compiler then you should be using `nullptr`. | |
Re: What is the value of count when you exit `for (; x <= userMax;)`? | |
Re: backslashes should be `\\` since `\` is an escape character. Try: infile.open("C:\\Projects\\C++\\infile.txt"); outfile.open("C:\\Projects\\C++\\outfile.txt"); | |
Re: Is `imgtest` a pointer? I am guessing it is not because of the error : "ambiguous overload for 'operator!=' (operand types are 'image' and 'int')" If a type is not a pointer you should not try to comapre it to `NULL`. `NULL` is just `#define NULL 0` so anywhere you … | |
Re: Sounds like this is something you should do yourself. If you have code and you are having problems with it then post the code you have and what problem you are having. If it is a compilation error included the error from the compiler and what line it is referring … | |
Re: Go through the string and change each letter to uppercase. You can use [toupper()](http://www.cplusplus.com/reference/cctype/toupper/) to make life easy. | |
Re: Are you having an issue with your code are are you just showing us it? If you are having a problem explain what it is. If you are having compiler errors tell us that the error is and what line it is happening on. | |
Re: To get a double one of the numbers needs to become a floating point number so the compiler knows to do floating point math. bmi = static_cast<double> (703 * weight / (height*height)); //BMI calculation becomes bmi = 703.0 * weight / (height*height); //BMI calculation As an FYI if none of … | |
Re: `main()` needs to be moved from line 105 to line 6. It should also be `int main()`. `main()` should always return an `int`. You also need to get rid of lines 108-110. You should also add a break after case 1. | |
Re: What happens if you run the code? I can tell you `5%3` is 2 not 1. `%` works as `5 - ((5/3) * 3)` or `a%b = a - ((a/b) * b)`. Line 4 should be 7 based on [order of operations](http://en.cppreference.com/w/cpp/language/operator_precedence). | |
![]() | Re: Why not use `std::wstring` instead of `std::string`. Then you can call `std::wstring.c_str()` which will give you an `wchar_t*`. ![]() |
Re: You are playing with undefined behavior. You should never go past the end of an array. Just because it worked doesn't mean it will always work. What you actually did was to write data into memory that `p` has no control over. The compiler does not check these conditions for … | |
| |
Re: It would only be fair. Unless he wants to pay for the work to be done. I'll offer my services for $250 USD per hour. | |
Re: 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 … | |
Re: `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. | |
Re: This isn't really a C++ problem. Try uninstalling the program and reinstalling the program that uses EEDE77.ccp | |
Re: There is an entire standard header file full of functions to do this. Check out [ctime](http://www.cplusplus.com/reference/ctime/). | |
Re: You can learn all about this problem [here](https://www.daniweb.com/software-development/cpp/threads/90228/flushing-the-input-stream) | |
Re: And you have done what so far? We do not do your homework for you on this site. | |
Re: Use an if statement and check to see if your files are actually open. You can do that with if(!infile.is_open()) cout << "Input file not opened!"; if(!outfile.is_open()) cout << "Output file not opened!"; | |
Re: 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 (\) | |
Re: line 32 should be `int IteratorTablou(int *crt = 0): crt(_crt)` You should also be returning a value from the function since you have an `int` return type. If you don't want to have a return then make the function `void`. | |
Re: @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()); | |
Re: Is your student class also a linked list? | |
Re: Do you have graphics.h on your system? From what I remember graphics.h is a very old deprecated header from the good old DOS days. I wouldn't think it would be in GCC 4.x. | |
Re: What is giving you the problem? We are not here to do your homework for you. | |
Re: I like to use the website: http://www.cplusplus.com/reference/ | |
Re: Since this is posted in the C++ forum how about: std::cout << "*\n***\n*****\n*******\n*********\n*********\n*******\n*****\n***\n*"; | |
Re: What need to know is how things are [passed by reference or passed by value](http://stackoverflow.com/questions/373419/whats-the-difference-between-passing-by-reference-vs-passing-by-value) | |
Re: 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) } | |
Re: [fstream](http://www.cplusplus.com/reference/fstream/fstream/) | |
Re: [Here](http://en.wikipedia.org/wiki/Vehicle_routing_problem) is a good wiki that should start you on your path. This is a NP complete level problem which is going to require a lot of work. | |
Re: line 249-250: `do {` lines 267-274: if(bValid) { for ( i = 0; i < nInterval; i++) { y = (nStart + 1) % 5; viewStudentRecord(c, y); } } while(ch != 'Q' || ch != 'q'); } The closing brace where while is at is actually the closing brace for … | |
Re: What is the problem you are having? Are you getting any errors? | |
Re: So what seams to be your problem. Just posting your homework will get you nowhere. I will offer to do it for $1000 USD that that is a limited time special offer. | |
Re: -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 … | |
Re: Your algorithm is a little wrong. Here is how you can do it (pseudocode): string first, second; // get the data for the string for i = 0 to i < first size - second size if (substring(first[i], first[i+second size]) == second) counter++; | |
Re: There is a lot of information here: http://en.wikipedia.org/wiki/Methods_of_computing_square_roots | |
Re: Herb Sutter has shown that you can use the following to shrink a container down string(str).swap(str); This will create a temporary string object with exactlly what is left in `str`. then it swaps that new smaller string into `str` and puts the bloated one in the temporary. then the temporary … | |
Re: What are the errors the compiler is giving you? Al so formating of you code is terrible. Code block should look like either of the following some line of code; if (some condintion) { some line of code; another line of code; if (another condition) { some line of code; … | |
Re: I'm still rocking a floppy at work but it is a USB external floppy. The machine I have also has a serial port and that was hard to come by. When will computer manufactures realize that stuff built in the 80's-90's still works great today? | |
Re: getting a runtime error points suggest that you are going out of the bounds of the array. What I wold suggest is that in your get and set methods you put in an if statement that checks to see if you are out of bounds and if you are then … | |
Re: This post seems a little nonsensical. `"t6"` is not a char but a string. What is the type of arraystr? Why are you storing the answer into int's? | |
Re: Well you can either use [command line arguments](http://www.cplusplus.com/articles/DEN36Up4/) and code your program to accept and use those or you can just call you program and have the program ask you for what it needs. // example of ussing command line arguments c:\programFolder\program.exe -inputFile input.txt -outputFile output.txt // program output here … |
The End.