419 Posted Topics
Re: If its C++ then you should post in the C++ forum. You should also post the code that you have so far. What you need is a float that holds the total of all the items being entered. A float to hold the amount of money the user gives. Then … | |
Re: If you want to be able to alter the output you have to use variables not hardcode in the letters. For this I used a string of characters alpha and placed them into the output. [CODE]#include <stdio.h> #include <stdlib.h> int main() { char cMarker1; int i = 1; char alpha[] … | |
Re: If you wanna store the names like [ICODE]a = ant[/ICODE] you should use strings (char*). [CODE]#include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> #define sz 12 int main() { int i, j; char* animals[sz] = {"ant", "bear", "cat", "dog", "emu", "goat", "lizard", "monkey", "parrot", "rabbit", "snake", "tiger"}; char* chosen[4] = … | |
Re: Looks fine to me. Use floats or doubles instead of integers since ints do not hold decimal places. | |
Re: This is the C forum so this is how you could do it in C [CODE]#include <stdio.h> #include <stdlib.h> int main() { int i; for( i = 0; i < 256; i++ ) printf("%c",i); return 0; } [/CODE] For C++ you could do this [CODE]#include <iostream> using namespace std; int … | |
Re: You can try to use a math function like y=2^(x/3) set your x and y coordinates for the ramp (it would look like [URL="http://www.wolframalpha.com/input/?i=y%3D2^%281%2F3*x%29"]this[/URL]). The function looks like a ramp and depending on the increment for x you can make it more or less smooth and you can change the … | |
Re: Lets see some of your code. Then we will know what areas to help you with. | |
Re: Why cant you use something like this? The only variables in the formula are 'k' and how many times it loops, not sure why you ask for input when the number 4 is constant. [CODE]#include <iostream> #include <cmath> using namespace std; double approachPi() { double sum = 0; int size … | |
Re: You could use a map to help decode the message. [CODE]#include <iostream> #include <map> using namespace std; int main() { map<string, char> cipher; cipher["45"] = 'd'; cipher["32"] = 'o'; cipher["34"] = 'v'; cipher["56"] = 'e'; string encoded = "45323456", decoded = ""; for( unsigned int i = 0; i < … | |
Re: You make a new thread, show your code and tell us some of the problems you have. | |
Re: You should use the C++ headers rather than c headers. If you need to use a c header like <string.h> use <cstring>. You probably have to fix the layout since 1-9 looks fine but when you get into double digits the column numbers don't line up. [CODE]#include <iostream> //use C++ … | |
Re: You need to include the <cstring> header | |
Re: I would recommend using Code::Blocks because I find it easier to use than Visual Studio and those are the two that people should use for windows. You can download it [URL="http://sourceforge.net/projects/codeblocks/files/Binaries/10.05/Windows/codeblocks-10.05mingw-setup.exe/download"]here[/URL] (this comes with the MinGW compiler pre-installed). To make a new C project start up Code::Blocks and then click … | |
Re: I changed your reverseDigit() function so it will actually store the answer to a digit using / and % like you have. The reason why you get an extra 1 at the end of the output when you keep return b is because you have it printing out in the … | |
Re: Declare two floats - area, radius. Take in input for radius. area = 3.1415 * radius * radius Output area. If you don't know how to do input/output or even declarations then you should go read a book or something. | |
Re: You can use pretty much what firstPerson suggested but get rid of the dollar sign and commas with one function. And replace_if by itself doesn't actually delete the characters you do not want, it just moves them to the end of the string, so use erase() to trim the string … | |
Re: [URL="http://en.wikipedia.org/wiki/List_of_OpenGL_programs"]here[/URL] are a bunch of games/applications that use OpenGL. And you said other than WoW even tho that uses both Direct3D and OpenGL (depending on platform). OpenGL and Direct3D are just like mac and windows, people have their preferences. | |
Re: [CODE]bool is_prime(int n) { for(int i = 2; i <= sqrt(n); i++) <---- use sqrt(n) {if(n % i == 0) return false;} return true; }[/CODE] The algorithm is from 2 to sqrt(n) not n/2. | |
Re: Make two "layers" for your game. Have one render the 3D world (perspective) and the other for rendering the HUD (orthographic). Only apply your camera transformations to your 3D world layer and set your camera position to 0,0,0 for the HUD layer. | |
Re: Courier New is the font that I use in code::blocks and 'i', 'L' and '1' don't look all the same. Note: if you type into the post editor the font is Courier New but the actual posts use a different font that has very similar characters for the 3 characters … | |
Hey I am running into a problem with CoCreateInstance() in a program that I am using to try to disable all the network adapters. When I try to use [CODE]hr = CoCreateInstance(CLSID_ConnectionManager, NULL, CLSCTX_LOCAL_SERVER | CLSCTX_NO_CODE_DOWNLOAD, IID_INetConnectionManager, reinterpret_cast<LPVOID *>(&pNetConnectionManager) ); [/CODE] I get two errors. undefined reference to `_IID_INetConnectionManager' undefined … | |
Re: The reason why the boarder is gray is because your clear color is gray. As for why it is not scaling up is unknown to me without seeing your glTexParameteri() functions. When I made my tile game I used: [CODE]glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); … | |
Re: The format of your if() statements is completely wrong. The structure is: [CODE]if( condtion == value ) { //actions } [/CODE] So for your Addition check you want something like this. [CODE]if( a == "add" || a == "+" ) { cout << "the answer is "; cout << addition(num1, … | |
Re: Why don't you just get input as a string and go through it and store all the numbers into a new array. for example: [CODE]#include <iostream> using namespace std; int main() { string line, flipped = ""; cout << "Please enter a string of numbers (ie \"12345\"): "; getline(cin, line); … | |
Re: There are quite a few problems with this code. #1) The run-time error is caused because you are trying to remove the first two digits of your decimal input and it is crashing because you use the itoa() function which takes an integer and converts it into a cstring. You … | |
Re: Try calling srand() right at the top of main() and only do it once (delete all the other times you call it). I did this and it seemed to fix the problem with the player getting dealt the same card twice. | |
Re: On line 22 you are setting space to 1 when you increase the length. I'm pretty sure if you take that line out you should be good. | |
Re: Since you know the data is separated by a ',' then you have to read in the data in chunks between the ','. Below is some code I quickly threw together that takes in the data from the text file and stores it into data[]. data.txt [CODE]abc,cde,fgh,jkl,rty qwe,erty, tyujk,werty,lkjh[/CODE] main.cpp … | |
Re: This depends on what you mean by graphics. OpenGL/GLUT since GLUT makes it very easy to use graphics without knowing anything about OpenGL. | |
Re: You need to make sure it is a project and then click the blue gear to build and the blue arrow to run. If that doesnt work then you should make sure you downloaded the install with MinGW. | |
Re: Are you including both in main.cpp? This could be your problem and the solution is to use preprocessor blockers SortData.h [CODE]#ifndef SORTDATA_H #define SORTDATA_H class SortData { }; #endif[/CODE] And do the same thing for InsertionSort.h but with a different blocker name | |
Re: Not sure if tabs and newline characters count but its been trimmed a bit too [CODE]#define X scanf("%d",& main(s,n,t){for(X t);t--;){X n);s+=n;}printf("%d",s-1);}[/CODE] | |
Re: It looks like the problem is with your outer for() loop because you are starting from 7 and going down to 1 (since its >0). Index 7 is out of range and 0 is used so you will be missing information and getting junk info. [CODE]#include <iostream> using namespace std; … | |
![]() | |
Re: The solution is in the if() statement where it prints either a * or space. You should use the C++ headers if you are using C++ ( you were using iostream.h instead of iostream ). And you should practice formatting your code so it is easier to read because you … | |
Re: In your while() loop condition that actually pulls a line out of the file and stores it into line so you are reading every second line with your code. Also you are overwriting your holding variable bit with the 2nd column of information. The only part that is really different … | |
Re: When you are giving people code and you want them to read it you should make sure your formatting is consistent. Some of your {} are to the far left when they should be tabbed in once because it makes it harder to see what is going on with the … | |
Re: A simple way to think about it is that GL_PROJECTION is to camera and GL_MODELVIEW is to world objects. So if you use glTranslatef() in projection mode then you will be moving your viewing position or camera. And if you translate in modelview then you are moving the drawing point … | |
![]() | Re: I don't think you have to use any inheritance for the aRectangle class like your last post says. And the way I set this up I'm not too sure why he got you to use classes for Offset and aRectangle, unless he wants you use get() and set() functions to … ![]() |
Re: Like abhimanipal said go check out that website because it is really useful Here is something I made to show how to read in, sort, then output some data from a text file to a text file. [CODE]//#include <iostream> #include <fstream> #include <vector> using namespace std; struct PERSON { string … | |
Re: Above you have aPoint being passed into the distance function and you are displaying pt1's x and y values. Do you mean to pass pt1 into the function? Based on the code that you haven shown I cannot see anything else that could be causing the problem. | |
Re: I'd say the best way to learn is by trying to draw it out on paper with all the vertices labeled and make all the basic shapes outta quads to start with or jump use triangles if you feel a bit braver. | |
Re: You can make a timer class and have it check to see if it is past your time delay between movements. If it is then add the offset then draw otherwise just draw. I have a timer class if you would like to see/use it (its pretty basic). | |
Re: You have to tell the fstream object that you want to output with it by typing: [CODE]fstream out; out.open("output.txt", fstream::out);[/CODE] | |
Re: You can go into your project settings and make it a Win32 Windows application and that will hide the console window. | |
Re: If you want to check all the "boids" against each other but not themselves then you can use this. [CODE] int main() { //BOID boid[3]; no idea what data type/structure you are using for( int i = 0; i < 3; i++ ) //the boid index you want to compare … | |
Re: I see the problem at line 33 of your first post. Replace that line with [CODE]vector<User> &getUsers() {return users;}[/CODE] The problem is that you are getting a copy of the user then you are modifying that but not the original copy of it. | |
Re: The code I posted below shows two functions, one using global variables and the other using reference to variables, that could be used for keeping track of the score. If it is a small game I would just use the global variables since you do not have to fill out … | |
Re: A class is made up of functions and variables so you can not randomly throw in a function call like srand() unless it is within one of it's own functions. I would call srand() at the top of your main() function. [CODE]#include <iostream> //use iostream not iostream.h (.h is the … | |
Re: I have never seen anything like this but this gives the needed output. [CODE]#include <iostream> using namespace std; int main() { if( cout << "aa", 0) cout << "aa"; else cout << "dd"; return 0; }[/CODE] |
The End.