419 Posted Topics
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 … | |
Re: If a file is up one level from the current directory you can use ".." to access its parent directory. So you can write `#include "../main.h"`. | |
Re: It sounds like you set up the search directories fine, but doesn't seem like you actually linked the required libraries. Right next to the Search directories tab is the Linker settings tab, click this and then press the add button and add the required libraries to your project (you can … | |
Re: Your second for() loop is causing the crash because the first for() loop leaves i at a an index with a junk value since it increments then checks to see if ip_num is 0. There are two quick ways to fix this: 1) You can assume that ip_num is never … | |
Re: Show us what you have written so far and we can help you through it if you have any actual questions. Do not just post up a homework assignment and expect someone to do it for you. | |
Re: I'm not 100% sure why you are making a 100 element array to hold 24 indices. Also you are trying to treat an array like a function or something, but it is incorrect. There are a few ways of doing this but here is the way I think you would … | |
Re: No matter what, collision detection is just going to be a bunch of if() statements. The way that you prevent checking way more objects than you need to is by dividing all your objects into a [quadtree](http://en.wikipedia.org/wiki/Quadtree) or an [octree](http://en.wikipedia.org/wiki/Octree). You then check if your player is within one of … | |
Re: If you use [atan2](http://www.cplusplus.com/reference/clibrary/cmath/atan2/)(y,x) it handles divide by zero and what quadrant the angle lies automatically. | |
Re: First of all what scope is your gradebook[][] array declared in? Try putting this for your Modif() function: [CODE]void *Modif (double gradebook[][9], int Students)[/CODE] Not 100% sure if that will even do anything but I think it might change your array. | |
Re: If you think about it you can divide by just using subtraction and a for() loop. Since you have this function itoa() available I'm assuming you are only using integers, which means you do not have to worry about remainders/decimals. Not gonna give you any code because you clearly just … | |
Re: I have attached a rewrite of your program because if you ever want future help your code has to be structured. I would recommend having main.cpp with pretty much just main() in it so you can read the flow of the program and if you want to know what happens … |
The End.