- Strength to Increase Rep
- +11
- Strength to Decrease Rep
- -2
- Upvotes Received
- 106
- Posts with Upvotes
- 98
- Upvoting Members
- 78
- Downvotes Received
- 8
- Posts with Downvotes
- 7
- Downvoting Members
- 7
419 Posted Topics
Re: I wrote something for this and if you want to put in more numbers its really easy (not as easy if you would just use arrays) if you read the code and see what I'm doing. [CODE]#include <iostream> using namespace std; int main() { int n1, n2, n3, n4, n5, … | |
Re: Here is a method using recursion that you could use. If you would want this to work with rocket mania then you would need to do checking to see if the two pipes line up rather than just replacing the character like the function does below. [CODE=C++]#include <iostream> #include <cstdlib> … | |
Re: Would look more like a circle if the characters were square and line spacing was the same as character spacing. [CODE]#include <iostream> using namespace std; int main() { double r = 1.2; for( double y = -r-0.1; y <= r+0.2; y += 0.1 ) { for( double x = -r-0.1; … | |
Re: This sounds like a trick question to me because if n was 50 or something and I gave the input 20, 30, 21, 49, 1, 35, ... 0 how would you be able to sort that without having a variable for each input. To "sort" a bunch of input in … | |
Re: You can use `System.IO.Directory.GetFiles(DIRECTORY_NAME);` which will return an array of strings that contain all the files (with full path) in that folder. | |
Re: I am not a Unix/Linux user so I am not 100% sure but after reading [on GetOpt here](http://www.gnu.org/software/libc/manual/html_node/Using-Getopt.html#Using-Getopt) and [a GetOpt example here](http://www.gnu.org/software/libc/manual/html_node/Example-of-Getopt.html#Example-of-Getopt) I would say the short answer is you must write `myprogram.c -t file1 file2 file3` because it parses for options first. | |
Re: I know this is a bit late and you may have come up with a solution already but here is a method you could use. pbGameBox is a PictureBox object from the C# Toolbox. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; … | |
Re: Line 18 of what you posted makes no sense. It will always select maximum = maximum in the trinary operator and you cannot declare a variable equal to an undeclared variable (even if you could it would be holding a garbage value). Line 19 you are now saying that the … | |
Re: I would suggest that you do not try to store all your information in labels, but rather have seperate variables that control the amount of each stat that your character has and then display those values in the labels. I tossed together a quick example of how you can use … | |
Re: Not sure why you are switching values in the b array or why your swap function uses loops. #include <iostream> using namespace std; int main() { const int N = 3; double *a = new double[N*N]; double *b = new double[N]; double *x = new double[N]; a[0] = 9; a[1] … | |
Re: Do you mean the constructor? You make a public function within the class that has no return (not void) and also has the same name as the class. #include <iostream> using namespace std; class Square { int _side; public: Square(){}; Square(int side) { _side = side; } }; int main() … | |
Re: Line 17 should be `display->array = (char **) malloc(sizeof(char*) * height);` Note that it is `sizeof(char*)` not `sizeof(char)` because you are trying to allocate char pointers which have a size of 4, where a char has a size of 1. Also your display function will not work as intended because … | |
This is a timer class that I wrote a while ago (cleaned up a bit for the snippet) for adding delays in some of the games I have written over the years. Note: I normally have the class functions in a .cpp file but since it looks like I can … | |
Re: Show us what you have done and we can help you if you state what problems you run into. We will not just do your homework for you. | |
Re: If your function is always going to be composed of `A*x^0 + B*x^1 + ... N*x^n` then why don't you integrate the function analytically and then evaluate it at the bounds x1 and x2 and subtract them. example: `f(x) = 10x - 5x^2` `x1 = 1, x2 = 5` `int(f(x)) … | |
Re: `int compare (const void * a, const void * b)` The two values 'a' and 'b' are of type void pointer and we want this function to compare two integers so we must convert from void pointers to integers. To do this we first cast the void pointer into an … | |
Re: If you are looking to make games I would go with C++/OpenGL or C++/DirectX or C#/XNA. I have never used C# but since it is a newer language and since it was made by microsoft it would probably be very easy to make windows programs and games using their XNA … | |
Re: Do you want the one function to be able to output both shapes? | |
Re: You would have to use a custom data type. A double can only hold so much precision. | |
Re: strcpy() works with c-strings and those are arrays of characters that have a '\0' terminating character. You are using a C++ string and they have the '=' operator overloaded so you just have to write string1 = string2; and that will copy the contents of string2 into string1. I would … | |
Re: If you are new to game programming then you should start with a 2D game. There is a massive gap between 2D and 3D if you plan on writing any of your own code (physics or other engine elements). | |
Re: If you have the function prototypes within the class and you want to define them outside, you need to define them with the proper scope. Right now you are just declaring some functions in the global scope. To define the class's functions you need to include the scope of the … | |
Re: why do you have the return 0; line out of main()? | |
Re: Well line 86 is going to have the same problem. | |
Re: If you were to throw `return user;` at the bottom of your function the error would go away. This is because if for some reason it did not go into your using statements it would never see a return statement. | |
Re: If you don't want to use the table you can just use a program to print out what the char for those hex values would be. #include <iostream> using namespace std; int main() { char message[] = { 0x4B, 0x50, 0x7B, 0xF1, 0xF4, 0xF5, 0x5E, 0x50, 0x7B, 0xF1, 0xF4, 0xF5, … | |
Re: You obviously didn't read the other thread that you started. I posted code that would output what that is and I said it is not a word or words it is just junk. | |
Re: How about you post up some code and then show us exactly where you are having problems. Writing out a big mal-formed paragraph isnt going to make us help you. | |
Re: When I used SDL for graphics I don't ever remember using SDL_GetKeyState(); however, it could have been just a preference that the writer turtorials I followed had. My suggestion (it might not be the best option) is to create your own bool array to manage the key states. You can … | |
![]() | Re: > At any point of time, I am asked to return the kth(it is given initally) minimum element from the elements read so far. When I read this I can interperet it three different ways: 1) You are at the 'kth' element and you want to know what the minimum … |
Re: There are a few things wrong with your code and you can make a few improvements too. You are getting those errors because your syntax is wrong. If you wanted to input that equation it should look like `cout << (storage_f_to_c - 32.0f)*5.0f/9.0f << endl;`. So not only is the … | |
Re: I find it funny how you are just spam posting really short questions and not really going into any detail. No one will help you if you don't do a bit of work and show us that you have done a bit of research on your end. | |
Re: Or instead of using an int array you could use a map (or unordered_map if you have a compiler that supports C++11). Accessing the values would be exactly the same but instead of having an array with a size of 97 + 26 (because 'a' is 97 (as said above) … | |
Re: > while( clock() < end_time ) ; > > Sorry, but that's a horrible suggestion as it consumes all the cpu time leaving little or nothing for other windows programs. Would this result in hogging the CPU too? I use this lots and after reading this I am wondering how … | |
Re: > By the way 120 can be of any base from 3 to inf. Thats exactly what hes getting at. If you want to convert A2C3 you have to say what base it is in because this could be anything from base 13 to infinity the way you see it. … | |
Re: What that means is that you do not have a main() function present in your code. I have a feeling that you are trying to compile just this file on its own. What you need to do is include this file in a project that has a main() function and … | |
Re: From reading the wiki page for [Greatest common divisor (GCF)](http://en.wikipedia.org/wiki/Greatest_common_divisor) it show to use Euclid's algorithm to find the GCF. The link that shows some pseudocode for using the algorithm is [here](http://en.wikipedia.org/wiki/Euclidean_algorithm#Implementations). And here is a recursive implementation. int GCF(int a, int b) { return ( (b == 0) ? … | |
Re: Why don't you treat this like two 1D boundary conditions ([like the other post that was solved](http://www.daniweb.com/software-development/cpp/threads/429999/periodic-boundary-conditions#post1843619))? If you create a position structure (just contains two ints or doubles for x and y position) then you can return that rather than creating a 4x4 matrix (which you did not allocate … | |
Re: What is the maximum value you are putting into these shorts? Are they signed? If you are not filling the shorts right up, and they aren't signed, then maybe you can get away with packing them all into maybe 12 bits rather than 16 (a short is 2 bytes (16 … | |
Re: I don't know what this "sth" is and I don't know what assumptions you are making as far as the size coming in goes, but here is a method you could use. int boundary( int pos, int step, int size ) { return (pos + static_cast<int>(size/2) + step)%size - static_cast<int>(size/2); … | |
Re: You can use strings rather than chars. If you do not want to read in spaces then you can use cin as your method of input. If you want to include spaces (something like a frist and last name) then you need to use getline(cin, str) for input. | |
Re: I would like to say that I agree with WaltP and that you should start off with learning the language before trying to hop into making a game with graphics. The first game I ever made was black jack in a console window (looking back on it, it was a … | |
Re: I'm pretty sure that in Java, like C++, if you pass an array into a function it automatically passes by reference. This means that you do not have return the array to upadte it in main(), since every change done to the array is done where the array is actually … | |
Re: I kind of see what you are trying to do with the nested for() loops but it is wrong. For distance I would just make a function that takes in the two coordinates, or this 4 element array, and then just plug it into the formula. Also in C++ you … | |
Re: In <windows.h> ERROR is defined as 0. So unless you were to undefine ERROR before your enum you would be writing enum ERR_CODE { SUCCESS, 0 }; because the preprocessor just does a "find-replace" for ERROR and swaps it with 0. A quick solution would be to just define SUCCESS … | |
Re: There are a few methods for finding the det of a matrix. [Here](http://www.purplemath.com/modules/minors.htm) is an example for using the minors method. | |
Re: On line 16 you need `scanf("%d", &a[n-1]);` It was not working because scanf() takes in a pointer to the variable in which you want to write to. The reason why you need to write to n-1 is because if you have an array that has a length of 5 the … | |
Re: The code that you are using for checking who wins is pretty bulky. If you just treat the hands like 0, 1 and 2 and that higher numbers beat lower numbers with the exception that 0 beats 2 then you can just use the mod operator to wrap around and … | |
Re: If you want to you can create aliens using the new operator and store them directly into the vector instead of creating aliens individually then storing the reference of them into this vector of pointers. std::vector<Alien*> aliens; aliens.push_back(new Alien()); aliens.push_back(new Alien(100, 200, 30, 30, 1, 172)); You just have to … |
The End.