419 Posted Topics
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 … | |
Re: itoa() is in <cstdlib> but is non-standard (meaning it is not implemented by all compilers). [This](http://www.cplusplus.com/reference/clibrary/cstdlib/itoa/) page shows an example of an alternative method using sprintf(). I'm pretty sure you could also use stringstream. | |
Re: As far as functionality goes it works; however, you shouldn't be using labels/gotos because they are a bad coding habbit and make reading the flow of your code harder. Anywhere you use a goto statement you can replace it with a loop (which is what I did in this case). … | |
Re: Show us that you have done some work on this by yourself. Post up a program that creates an array, fills it (either hardcoded or by user input) and then your attempt at removing duplicates. After that I will be able to help you out, otherwise you will learn nothing. | |
Re: On line 11 your function prototype says that approximateSqrt() takes no parameters so that is where that error is coming from. To fix it change that line to `double approximateSqrt(double);` | |
Re: On line 6 you want to use "rb" not just "r" because just using "r" would read one character at a time. If you have a bunch of integers in your file that are two digits long but are represented as 4 bytes you will be reading only two characters … | |
Re: Where is your `gluPerspective()` call? Since I don't see where you are positioning the "camera" or "viewer" you might not have the correct far value. | |
Re: Why don't you show us your code for a linked list and your attempt at getting min, max and counter functions to work. | |
Re: 5050 is the sum of the numbers from 1-100. You are printing the value returned from counter in main() so it will only print once. If you want to print all the numbers from 1-100 you should have your print statement within the recursive function and you do not need … | |
Re: You should really start a new thread for new questions since this is a really old thread. To find a char in a string you can use the find() member of the string class and get the index of it. example: [CODE]#include <iostream> #include <string> using namespace std; int main() … | |
Re: Your code will not enter the inner for() loop because you have [ICODE]c = 0[/ICODE] right before it and your condition is when [ICODE]c > 0[/ICODE]. | |
Re: You don't have a display function or an idle function. Not 100% sure if this is the problem since I haven't used glut in a while but from what I remember you need them. | |
Re: Try starting with this [CODE]#include <iostream> using namespace std; void MyFunction() { //does something } int main() { MyFunction(); return 0; }[/CODE] | |
Re: The variable ans is initialized but not set. Right before your for() loop you should write [ICODE]ans = num;[/ICODE] otherwise ans will just have a garbage value in it. [B]EDIT[/B] Or you can change line 7 from [ICODE]cin >> num;[/ICODE] to [ICODE]cin >> ans;[/ICODE]. | |
Re: Like VernonDozier said, you are declaring 'char c' out of scope but there are also a few other errors within your program. You are calling the function srand() at the start of the for() loop on each iteration which results in all the characters being the same. The solution to … | |
Re: The function is not bugged you just didn't read the documentation on this function. The way you have it set up you have two major problems. #1 left and right values cannot be equal #2 near and far must be both positive If you were to write out the resulting … | |
Re: Best way to figure these types of problems out is by using some paper. Draw each case you want on paper (in this situation you want to see four ways another box can hit the "hittee") then write out the conditions that have to be met. Also what happens if … | |
Re: If you do not want the background to move then you will have to draw it first then translate the rest of your scene based on the position of your camera or whatever is moving right now. If you want the background to go forever and move it then you … | |
Re: If you wanna do a quick n dirty transpose on output just switch your i and j values when printing out. From [ICODE]out[i][j][/ICODE] to [ICODE]out[j][i][/ICODE] will output the transposed matrix assuming that it is a square (#rows = #cols). If you don't know if #rows = #cols then you do … | |
Re: I haven't really touched C# before but I'm pretty sure (since in C++ you have to) you need to have BaseClass as an abstract class and then declare someMethod() as abstract within it. This is because you are trying to call a function in SubClass when BaseClass has no idea … | |
Re: I take it you want to make a multi-dimensional array so you can store all the words into one array and then use a for() loop to populate/sum the values. You can merge the two for() loops into one but if you were to join them then why take the … | |
Re: For the most part the code is pretty good. You made a few minor errors that would be expected since you are still starting out but you should really work on consistency in indentation since it is harder to read and edit (you will really notice this later on) so … | |
Re: Without actually knowing how it is implemented and by only playing around with these two classes it seems when there is a name conflict (in this case x) the default scope to be used is that of the class that is calling it. When inheriting another class the class that … | |
Re: Start with "Hello World!" then add to it. Then come back and as for help when you have something to show. | |
Re: A quick solution to what you want is to just move your topping selector to the Pizza class since you pretty much have a circular reference with your derived class sitting inside of your base class. I threw together a simplified version of what I think you are trying to … | |
Re: After fixing a bunch of typos and added to the bottom of Advanced2D.cpp (you have the extern prototypes but you do not actually make the functions) [CODE]bool game_init(HWND in) { return true; } void game_update() { } void game_end() { } bool game_preload() { return true; }[/CODE] Make sure you … | |
Re: He sets it to NULL (or 0) because that way he doesn't reprint the same message constantly. Whenever you press a key message becomes non-NULL and it redraws and this has nothing to do with the program quitting. | |
Re: Did you figure the problem out? I see it is marked as solved but you didn't edit your post or post your solution. The problem I see is that you are missing an if() to go with your bottom else statement. | |
Re: If this is all the code you have for your DC and drawing then the problem is that you aren't drawing to the correct DC that you might think you are. In WM_CREATE: you are creating an HDC object and then setting it to the current DC. After this case … | |
![]() | Re: rand()%RAND_MAX should generate [0,32767) meaning the number will never be 32767. If you want it to include 32767 then just use rand()%(RAND_MAX+1). ![]() |
Re: A normal is a vector and the dot product returns a scalar. To calculate the normal of a plane when you know two vectors along that plane then you use the cross product (because it gives a vector perpendicular to the plane aka the normal). The equation of a plane … | |
Re: I compiled this with Code::Blocks and Visual Studio and both worked just fine. | |
Re: Based on what you posted you have just made your prototypes but you have not actually defined any of the functions. | |
Re: The issue lies within your function gasket(). On line 34 you are missing an equals sign between point and T, so it should look like [CODE]GLPoint point = T[index];[/CODE] Then when you are adding point.x and t[index] then dividing by 2 you really want to add each component then divide … | |
Re: It looks like all your errors/problems are in "cdrom.cpp". In the function CDROM::setName() you have [ICODE]getline(cin, name)[/ICODE] being printed out in your cout statement. The function getline() returns *this which is a pointer to the istream object being used (I think, either way this is not what you want). Also … | |
| |
Re: Those are warnings and that is because you have no included <stdio.h>. ![]() | |
Re: Your function prototypes are different than your function definitions. In the prototypes you are expecting a pointer to a vector where in the definitions you are expecting the reference of that object. | |
Re: Funny thing is that you just copy pasted your assignment without even posting assignment #3 which is referred to in this one. Post what you have so far (and not the original assignment #3) and say what you need help with. | |
Re: How are the phone numbers and names stored in the file? Can you give us a sample? | |
Re: It's not so much about we don't wanna give you the answer without you putting any thought into it, but the fact that you won't learn anything and you will probably be asking the same question around this time next year. Give it a shot and there are people that … |
The End.