419 Posted Topics
Re: You can use the % (mod) operator to get the remainder of one number divided by another. ie 72 % 10 = 2 <--- your first digit | |
Re: First off I would switch from Dev-C++ because it is a dead IDE. Use Code::Blocks or Visual C++ that is more current (I use Code::Blocks and had switched from Dev-C++ -- the transition wasn't that hard). As for the whole having a window and cmd prompt up at the same … | |
Re: I switched made the function return a bool because you are returning false on a void function and ran it and it "broke" and made my motherboard speaker go off like a christmas song for like 3 min. | |
Re: Use a do{}while() to loop in main() I would not recommend calling main(). [CODE]int main() { char askLoop; do //do enters the loop weather or not the condition at the bottom is met on the first run { double tax, pay; termlength_determine(); cout << "how much do you get paid … | |
Re: It would take a while to write a program like this without flaws and you would have to think hard but if you look there is a pattern. There are never more than 3 of the same "digits" in a row and its always high digits to low digits, left … | |
Re: Windows uses handles for letting the user/program control elements of the Windows environment (not 100% sure how to explain this). So line 10 is getting the output handle and saving its memory address into the pointer hcon. This is then passed into SetConsoleTextAttribute() on line 11 and has its color … | |
Re: After looking over your code the problem seems to be in main(). You have it so when you input your selection it sets the choice and the space THEN checks to see if the space is 0 or not. This will never be 0 because you are setting it before … | |
Re: [CODE]#include <iostream> using namespace std; int main() { cout << "Hello world!" << endl; return 0; }[/CODE] This is the start of a program now go throw on some ints and add them together. Once that works figure out how to use a container ( list, vector, array... ) and … | |
Re: Not 100% sure why you are using an array to store your character since you are only using 1. Also when you make an array [ICODE]char answer[1];[/ICODE] that means that it has a size of 1 and it starts at 0 so you would use it like [ICODE]if( answer[0] == … | |
![]() | Re: Personally I would start with just using a single variable instead of trying to make a list work because that just adds more complexity to something that you are trying to figure out. And if you are going to then just use the std namespace to shorten and clean the … ![]() |
Re: Your expe keeps building because you keep adding itself with the new random exp to itself. If you want to just add the amount of exp for killing that goblin then you need to just assign the random exp gained to expe (like you did for loot). In other words … | |
Re: This example uses a do while loop to keep asking for the user input if it is not correct. A do while loop will enter the loop no matter what the value of the variable that you are checking against is but will check at the end. In this case … | |
Re: Way too much to see whats going on and the line numbers are off with your errors. Try to create a small program that uses your polygon class in a similar way to see whats going on with it. Plus this is C++ why not use a vector (or another … | |
Re: float rational would be of type float rational myRationalNumber would be type rational | |
Re: In the <ctime> header there is a function called clock() and it tells you in miliseconds the amount of time passed since the start of the program. If you are testing one algorithm this will mostlikly give a value of 1 or 0. A way around this is to run … | |
Re: This is an example using string stream and c++ strings using a similar format to what you posted above. [CODE]#include <iostream> #include <sstream> using namespace std; class DATE { int day, month, year; public: DATE(); DATE(string d); int GetDay(); int GetMonth(); int GetYear(); }; DATE::DATE( string d ) { stringstream … | |
Re: You can do 2 things for this. #1 save all the points into a container and plot them each time #2 make the board once outside of the infinite loop and plot the points on within the loop The following code shows #2 because I think it is the best … | |
Re: An easy way to think of a string is that its an array of characters in C and a vector of characters in C++. Meaning it can hold any character. If you want something like " ' or \ in it you need to put an escape character before it … | |
Re: I fixed it up so it actually runs but I removed the whole height_in_feet variable because it was not being used. Since there are so many errors I would suggest you relearn the basics of functions. Check this against yours and see where you went wrong. [CODE]#include <iostream> using namespace … | |
Re: The problem that really stands out for me is your output area. You are using [ICODE]cout << "text" << +a;[/ICODE] and [ICODE]cout << "text" << +a+ "moretext" << +b << endl;[/ICODE] When using cout only use + for adding numbers together. For output you just need to go [ICODE]cout << … | |
Re: Try this [CODE]slong** newarray = 0; for( int i = 0; i < limitsqr; i++ ) newarray[i] = new slong[limit];[/CODE] | |
Re: Made a few changes to it and it works fine. Read the comments. [CODE]#include <iostream> #include <string> //use string not cstring using namespace std; //move using namespace std; up here int main() { string str2; cout<<"Enter a line of input for str2: "; getline (cin, str2); //remove cin >> str2; … | |
Re: You guys know this post is 4 years old right? | |
Re: Also your formula for converting is wrong it is 5.0/9.0 not 5.0/8.0. | |
Re: The way you are doing it says int/int*(int*int)+int you want everything multiplied to be a float otherwise it converts it to an int. 1/2 gives the answer 0 because integers do not have decimals. 1.0/2.0 gives the answer 0.5 because doubles/floats do have decimals. So the way to write what … | |
Re: You need to add a break after case 1 because it just runs into case 2 which makes it output "twenty" Here is another way to do this with strings and arrays. [CODE]using std::string; int numToText(int num) //function to return text version of number entered { string ones[] = { … | |
Re: Not sure why you are making it so complicated and you are using a int function when the way you have it you could use a void function. [CODE]int SumIt(int x, int y) { if( x == y ) return x; int high = x, low = x, sum = … | |
Re: A .dll file is a dynamic linker file which has to be included with the .exe if you do not use the static linker file. If you add the .a or .lib file (static linker) then you do not need the .dll file but the size of the .exe will … | |
Re: I'm not sure what coefs is an array of (I'm guessing ints) but the pow() function returns a double so you would run into more casting problems there. I would just use the c-style casting for this problem unless you need to use C++ style type-casting. [CODE]sum += coefs[i]*(int)pow((double)x, (double)degree);[/CODE] | |
Re: Could have something to do with depth. Lets see some source code and then I'll be able to help you out more. |
The End.