General C++ Programming - February 2011 (Page 9)

Best way to code piecewise step function?
 
Hello everyone, Trying to code f(x) = [1 for 0<=t<1/2; -1 for 1/2<=t<1; 0 otherwise]. I wrote: #include <iostream> using namespace std; int main() {...
[4 replies] Last: Thanks guys! I got it :) (by siegel14159265)
by joshky
64 vs 32 bit
 
If I upgrade from windows 32 bit to 64 bit will it change the portability of programs that I compile on my machine? What other issues will this cause from a pr...
[3 replies] Last: Ok, I have never tried developing from win64 platform, but I want to c... (by simeonz)
by aj3423
read last 5 lines of a file using stl fstream
 
like the tail command on linux, is it possible to implement using c++ stl fstream? do a reverse lookup for the last 5 lines ( which means not read whole fi...
[9 replies] Last: I thought that the standard defines fseek for text mode when used to s... (by simeonz)
Mutexes ~~lol~~
 
Just a quick question on mutexes (looked up the correct plural form, this is as close as it comes) When I use a mutex, how would I go about checking if it's ...
[7 replies] Last: Haha Ya got that =D (by ultifinitus)
by ferros
openCV cvMorphologyEx() problem
 
Can anyone please give me some idea on cvMorphologyEx() function? I am a new guy in programming and openCV, and i really no idea on how to apply the function. A...
[no replies]
by chess
Tic Tac toe
 
Hi I would like to write simple code for Tic-Tac toe that just checks the rows and columns and diagonals for X or O and for X if it matches , it returns 1 and ...
[2 replies] Last: Hey chess.... do you want your function jto simply check and decide a... (by mrahsanahmad)
How to set the delim character in cin.ignore() to anything?
 
cin.ignore( INT_MAX, 'w' ) //Do not continue until w is pressed cin.ignore( INT_MAX, '\n' ) //Do not continue until enter is pressed How would I get it to...
[1 reply] : cin.get()? (by quirkyusername)
SDL Problems
 
Hey, I'm kind of new to SDl and I've been writing a couple of wrapping classes and for some reason my ocmpiler just cuts out on a certain line, here's the code:...
[5 replies] Last: dude, im writing a wrapper engine in SDL too, why are you locking, unl... (by Jaso333)
eval
 
I was just wondering - how would you make a function like Python's eval(), which solves an equation? For instance, if I give it 2*(3-(7*9))^2-4, it will outp...
[6 replies] Last: Indeed in the case of simple expression like this, one can use recursi... (by simeonz)
Installing a Compiler In Code::Blocks
 
I've downloaded the compiler for The D Language for Windows. Now that I have it, I don't know how to install it in Code::Blocks. I failed miserably trying to in...
[1 reply] : Never mind, I've done it. (by closed account zb0S216C)
count keeping
 
Hi all, Can someone help me with the command to keep count of the guesses that the user makes and display the number of guesses. #include "stdafx.h" #i...
[4 replies] Last: i added the lines below and the program works now; Thanks u very much... (by akounga2000)
Set precision isn't working...why?
 
My set precision doesn't seem to be doing anything. I'm following an example I found here on the Reference section. I'm dealing with money so instead of 0.8 out...
[6 replies] Last: The reason for your problem is because without the "fixed" keyword, th... (by packetpirate)
Text Adventure Problems
 
So I've been having problems with the use of strings in my class. #include <iostream> #include <string> using namespace std; int position = {0,1,2};...
[2 replies] Last: Damn. Just had to switch the two around. Thanks a lot! ;] (by HeWasLikeAGhost)
array size
 
hey guys i am writing a program that has lots of arrays. is this syntax not correct?? new_coefficients[i - 1] can you not do that? -thanks
[3 replies] Last: That syntax is fine. What are the possible values of i? (by rocketboy9000)
setting a range
 
hello! i am currently working on an array, and i want a user to only select between 1-50 (when inputting a number). i am so new to this, and the book does no...
[2 replies] Last: do this: int i; do{ cin >> i; if(i<=50)break; else c... (by rocketboy9000)
Is it bad practice to have multiple return statements in a function or method?
 
will having multiple returns make it more unreadable in contrast to having just one return statement as the last line in a function/method?
[6 replies] Last: I found this quote a long time ago: In languages with exceptions, ... (by PanGalactic)
Vector Strings- extracting particular strings
 
Hi,i have written a programme which asks the user to input a course name and a course code. The program then uses string stream to join the course name and coud...
[1 reply] : replace cout << *iterator; with if( (*iterator) == '3' ) cout << *... (by hamsterman)
checking for file existence
 
I'm making files to store data for a game I'm making. Theres a box that is going to display all the profiles and you will be able to select one. so how would i ...
[5 replies] Last: Check out FindFirstFile/FindNextFile/FindClose (by kbw)
Confused on Subtracting from struct element
 
Hello, My program is supposed to read from the user a soda name, the price and the quantity. Then the user makes makes a selection of what they want. Here'...
[14 replies] Last: Edit: Figured it out: void transaction (Drink machine , int &numite... (by skatingrocker17)
Nested Vectors or ye olde error C2679
 
Hi, I'm writing a server software with an onboard database using MS VC++2008 Express. Right now, it's the latter part that has me a bit stumped. I've creat...
[2 replies] Last: Yes, that worked once I modified my accessor method a bit. strin... (by Austin Covello)
February 2011 Pages: 1... 7891011... 25
  Archived months: [jan2011] [mar2011]

This is an archived page. To post a new message, go to the current page.