- Upvotes Received
- 1
- Posts with Upvotes
- 1
- Upvoting Members
- 1
- Downvotes Received
- 2
- Posts with Downvotes
- 1
- Downvoting Members
- 2
21 Posted Topics
I'm trying to come up with a small block of code that simply takes a character value that is input by the user and then use an "if" statement to determine what is excecuted depending on what is entered. I just started C++ this week and have no prior experience … | |
I am having a problem displaying random numbers, I'm trying to make a dice game where you play against the computer and the first one to 100 wins. However, my random number is never random, it always comes out as the same number. From what I understand to simply display … | |
alright, well the code I have is a complete mess and there HAS to be a better way of doing it as well.... it's right here [CODE]#include <stdio.h> #include <stdlib.h> int toExit(int exit){ while(exit != 1 || exit !=2){ printf("\n\nPlease Choose:\n1) Exit\n2) Run program again\nYour choice: "); scanf("%d", &exit); printf("\n"); … | |
I'm getting into some territory I have never treaded before.... What I have is an Abstract class "Person" with an abstract class "Employee" that extends "Person" and then three concrete classes within "Employee" named: Agent, Accountant, and WebDesigner. sudo: [CODE]abstract class Person{ abstract class Employee extends Person implements myInterface{ class … | |
I am trying to create an array of a custom object and I think the error I'm running into is that the objects within the array are not initialized prior to use (its a run time error, so i'm not entirely sure). The part that doesn't make sense is, if … | |
I have to calculate the number of days between two dates the hard way. I know there is already a way to do this with an existing package and such but I have to do it within a single method "daysBetween" without altering any other part of the code. The … | |
Is it even possible to create a singly linked list using a function outside of main and then access it once you leave the function? pseudo: [CODE]#include //whatever needs to be included function{ \\create and link lists in this function } main{ funtion()//call function to create lists and link properly … | |
I have to open and read a file whos file name is provided through a command line argument. Right now, I am using the following method. My main: [CODE]#include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> #include "functions.h" int main(int argc, char *argv[]) { int count, string_size; int other = … | |
I'm having a problem parsing information stored in the buffer after a getline command. I have a file with data in the format: [ICODE]1310 76102 C 5 27 2011 6 26 2011 5 R R 8.00 20.00 F R 8.00 25.00 150 165[/ICODE] I would separate everything using white space … | |
I'm trying to figure out a way to create a loop to open files and read in data until either there are no more files or the user wants to stop. for example, the first time through the loop, the string variable would be "myfile_1" and then each subsequent time … | |
I have a string that has a bunch of white space on the end of it and was wondering if there is a simple way to eliminate the trailing white space with a standard C function. I know there is one called "String.trim" but I can't use anything that isn't … | |
Re: [CODE]void name(char game[4]) { //your void function here } void main() { char game[4] = {'S', 'R', 'D'}; name(game) return 0; }[/CODE] You actually don't need to use the * because a funny little thing C does by assuming the index "game[0]" (the number in the brackets) is already a … | |
I have two different ways to traverse a tree adt that essentially do the same thing except one is a recursive function and the other is iterative. How could I compare the efficiency between them? RECURSIVE [CODE]inorder(node) if node.left ≠ null then inorder(node.left) print node.value if node.right ≠ null then … | |
Aside from using switch statements, do-while loops, and if-else trees, is there a good way to complete error checking after a user input from the keyboard? | |
Is there a way to evaluate cosecant^2 in c? As far as I know, it isn't included in the math.h library, but could there perhaps be another one that it is included in? | |
I'm working on a code that will multiply two matrices and print the result. This specific code is meant to ask the user to define the bounds of the matrices (i.e. the (M)x(N) of the matrix) then ask for each matrix by row. The trouble I'm having is that I … | |
I finished this last night and it almost works perfectly aside from one minor thing that I can't quite figure out. [CODE] #include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main() { int playerscore, computerscore; int turnscore; int dice; char input = 0; bool turnover, gameover; srand((unsigned)time(0)); playerscore … | |
Re: [QUOTE=kotkata;724503]Thanks for all the help, I just solved my problems.[/QUOTE] How did you solve this? I'm having basically the same problem. | |
Re: That ran fine for me, you may be having a problem because the cin.get is in there, in order for me to finish executing the program I had to press return again and then it terminated. cin.get() isn't doing anything, its just sitting in your code trying to look pretty … | |
This is a program that is meant to be a dice game with the computer, and this is what I have so far. I'm trying to make sure that I'm doing it right but I can't compile it to check because of a syntax error near the end of the … | |
I have a program that a friend wrote for me in Java, however I'm trying to put it in C++ and I don't know Java myself. Does anyone know somewhere that I can get it translated? Or maybe someone who has time to translate it themselves? It all looks vaguely … |
The End.