419 Posted Topics

Member Avatar for AKISS

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 …

Member Avatar for WaltP
0
88
Member Avatar for NewbieinC

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[] …

Member Avatar for sfuo
0
99
Member Avatar for ineedsomehelp:3

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] = …

Member Avatar for ineedsomehelp:3
0
382
Member Avatar for Zvjezdan23
Member Avatar for mrnutty
0
163
Member Avatar for shweta2008

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 …

Member Avatar for shweta2008
0
147
Member Avatar for sergent

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 …

Member Avatar for sergent
1
277
Member Avatar for mark_6
Member Avatar for Joemeister

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 …

Member Avatar for Tellalca
0
185
Member Avatar for thedalek

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 < …

Member Avatar for thedalek
0
201
Member Avatar for mehaksyeda@gmai

You make a new thread, show your code and tell us some of the problems you have.

Member Avatar for Ancient Dragon
0
66
Member Avatar for vergil1983

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++ …

Member Avatar for zomgser
0
229
Member Avatar for byrosport
Member Avatar for Chamath

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 …

Member Avatar for Chamath
0
157
Member Avatar for Rizi004

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 …

Member Avatar for Rizi004
0
168
Member Avatar for busty043
Re: C++

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.

Member Avatar for Narue
-2
144
Member Avatar for TheLittleEngine

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 …

Member Avatar for sfuo
0
164
Member Avatar for Labdabeta

[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.

Member Avatar for dvidunis
0
249
Member Avatar for kimkim0513

[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.

Member Avatar for TrustyTony
0
251
Member Avatar for pcgamer2008

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.

Member Avatar for pcgamer2008
0
269
Member Avatar for Labdabeta

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 …

Member Avatar for Labdabeta
0
86
Member Avatar for sfuo

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 …

Member Avatar for sfuo
0
392
Member Avatar for helpfullProgram

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); …

Member Avatar for helpfullProgram
0
262
Member Avatar for Bead

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, …

Member Avatar for l1nuxuser
0
161
Member Avatar for Tursup

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); …

Member Avatar for TrustyTony
0
135
Member Avatar for Tinee

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 …

Member Avatar for mike_2000_17
0
134
Member Avatar for jxe217

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.

Member Avatar for jxe217
0
213
Member Avatar for ak24

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.

Member Avatar for ak24
1
374
Member Avatar for Shruti4444

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 …

Member Avatar for sfuo
0
171
Member Avatar for geekme

This depends on what you mean by graphics. OpenGL/GLUT since GLUT makes it very easy to use graphics without knowing anything about OpenGL.

Member Avatar for Kanoisa
0
212
Member Avatar for geekme

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.

Member Avatar for sfuo
0
38
Member Avatar for yongj

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

Member Avatar for yongj
0
106
Member Avatar for cse.avinash

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]

Member Avatar for cse.avinash
-1
553
Member Avatar for mistereff

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; …

Member Avatar for sfuo
0
157
Member Avatar for luke710
Member Avatar for nssltd
0
93
Member Avatar for cookiemonstah

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 …

Member Avatar for sfuo
0
196
Member Avatar for stobbz

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 …

Member Avatar for stobbz
0
4K
Member Avatar for nxt200

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 …

Member Avatar for sfuo
0
131
Member Avatar for pcgamer2008

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 …

Member Avatar for pcgamer2008
0
170
Member Avatar for ghost_from_sa

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 …

Member Avatar for ghost_from_sa
0
978
Member Avatar for Nandomo

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 …

Member Avatar for Nandomo
0
117
Member Avatar for clickspiker23

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.

Member Avatar for ravenous
0
139
Member Avatar for Khoanyneosr

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.

Member Avatar for n.cramp
0
173
Member Avatar for pcgamer2008

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).

Member Avatar for pcgamer2008
0
124
Member Avatar for GhostMonkey

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]

Member Avatar for GhostMonkey
0
105
Member Avatar for Labdabeta

You can go into your project settings and make it a Win32 Windows application and that will hide the console window.

Member Avatar for Labdabeta
0
7K
Member Avatar for thehivetyrant

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 …

Member Avatar for sfuo
0
95
Member Avatar for Vanquish39

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.

Member Avatar for Fbody
0
151
Member Avatar for beejay321

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 …

Member Avatar for sfuo
0
140
Member Avatar for coolbeanbob

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 …

Member Avatar for sfuo
0
4K
Member Avatar for stevanity

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]

Member Avatar for L7Sqr
0
101

The End.