Beginners - March 2009 (Page 9)

Random number generator
 
I'm working on a DnD game and I need to know how to make a random number generator, say 1 to 50 for dice rolls and such. How would I do that?
[1 reply] : Use srand() ONCE to seed it, then call rand() for a random int. You c... (by firedraco)
errors with assert()
 
We are writing our own string class(mystring), and I am having a problem with my operator overload. The function works fine, but we are supposed to use an asse...
[2 replies] Last: duh! That's why I love this site. I had looked at it for too long wit... (by grcunning)
by berge
getArea() function
 
Hi! I have a class named Rectangle with the private members: double width; double height; I have a a get function which returns the area of the rectangle. ...
[4 replies] Last: I see! thanks! are there any rules for when I should use this->width, ... (by berge)
how to solve this task
 
WAP that allows the user to enter numbers till the user wants and at the end it displays the number of positive numbers, negative numbers and zeroes entered. ...
[2 replies] Last: Thank U!!! i have made the correction and now the code is working. (by blue cloud)
how can my program identify if input is a double or a int?
 
i want my program to accept ONLY double value and if the user put in a int the program dont accept it. how can i make my program do this?
[1 reply] : if you're querying the user for input, and want that input to be store... (by jRaskell)
Deleting Pointers
 
Hi do i need to delete the pointer. void test(){ char* pChar; pChar = new char ; strcpy(pChar, "ffsafafafa"); } int main(){ test()...
[3 replies] Last: It is not automatically deleted. You have to delete it. Generally ... (by jRaskell)
by newb17
problem tryin to read from file
 
im trying to read some info from a file but im getting this compiler error In member function ‘std::string FileReader::fileRead(std::string)’: 40: error...
[2 replies] Last: arr such a simple mistake. thanks (by newb17)
by jesusk
i cant find out the problem
 
this program is supposed to work with functions outside the main function ok? so ur asked for a program which will ask for aproximation number (n) and a value ...
[3 replies] Last: yeah i've noticed when i checked every function individually and the... (by jesusk)
List Files
 
Hi what function i need to use if i want to list all files in a directory. tnx
[1 reply] : There's no such function in the standard library. Either a) use syste... (by helios)
Illegal use of pointer function
 
I'm attempting to do a simple output where the int variable "creaturelevel" is shown to the user, but it's giving back an error that says: "oroperator.cpp": E20...
[1 reply] : Line 16: You're doing cout < instead of cout << . Line 27: Don't d... (by helios)
what wrong with my program.why it is cannot run?
 
#include <iostream.h> #include <iomanip> const float TAX=.06; void menu(); int main() { float total=0; bool done=false; char choice; menu...
[1 reply] : Well, I see multiple places where you would get an error. Is it giving... (by closed account S6k9GNh0)
Input tags separator
 
I've written the following loop that stores each line of a file into the row of a 2D array, item by item (i.e. word by word). Now it happens that the items s...
[3 replies] Last: Not a problem...the worst people are those who go: "OMG HW PROBLEM!... (by firedraco)
by jaydr
clearing screen
 
I have read the following already before anyone gets on me. http://www.cplusplus.com/forum/beginner/1988/page3.html I want to have my console clear the sc...
[2 replies] Last: i figured that out but i would like to do it right instead of the the... (by jaydr)
by Oromis
Create an empthy surface in SDL
 
How can I create an empthy surface in SDL? Is something like the following possible? SDL_Surface *mySurface; //create an empthy surface, setting the widt...
[1 reply] : See a reply to your other post on same subject. (by guestgulkan)
by wretch
comma operator: dangerous or useful?
 
Has anyone ever used the comma operator in their programs? i1 = (i2 = 2, i3 = 3); I mean using it in the context of using it for a meaningful reason...
[6 replies] Last: In general the operator is useful only in very specific circumstances ... (by jsmith)
Converting int to string C++
 
Hey, I need to write a code in my program to convert int to string like 1 will be USA 2 will be Australia 3 will be Canada this is just an exam...
[5 replies] Last: Yes, I meant n-1 so that if n==1 is returned n (the 1 st element)... (by Bazzy)
how to solve this task!!!!!plz....
 
How to do this assigment.im did not understand it..plz somebody help me.i will appriciate anybody who will help me. The program question are like this:- Th...
[1 reply] : Start with this: #include <iostream> int main() { std:... (by kempofighter)
by sobi
Menu-driven program in C
 
This is a menu driven program that allows a user to enter five numbers and then choose between finding the smallest,largest,sum or average.The menu and all the ...
[1 reply] : I'd love to help you but here are the problems. 1) you didn't use c... (by kempofighter)
how to solve this task
 
Write and exercise a program that allows the user to compute the number of days that elapse between two dates. Examples: There is 1 day between 6/7/1954 and...
[1 reply] : start with this #include <iostream> int main() { std::co... (by kempofighter)
Need explaining
 
#include <iostream> #include <cstdlib> #include <cstring> using namespace std; void salaryf(char *a); int main() { char salary ; char pou...
[6 replies] Last: Hmm well the right numbers are being outputted now but the "Current Sa... (by mcleano)
March 2009 Pages: 1... 7891011... 29
  Archived months: [feb2009] [apr2009]

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