C :: Create Structure That Stores Player Name And Score

Aug 8, 2013

We are told to modify this code following the instructions given within the code. It is a tictactoe program.

Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

// Create a structure that stores a player's name (up to 20 characters) and score (# of wins)
// Call the struct Player

void info(void) {
printf("

[Code] ....

I've ended up with the following code, but the part about the name of the datafile is giving errors upon running the program.

Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

// Create a structure that stores a player's name (up to 20 characters) and score (# of wins)
// Call the struct Player
typedef struct {

[Code] ....

View 4 Replies


ADVERTISEMENT

C++ :: Giving Score To Correct Player

Jul 22, 2013

I have programmed a game where you guess a number (1-6) and if the number is equal to the random number then give the player score + 10. But if I have selected for example 4 players then if the game will give player 1 a score it gives player 2 a score instead? What can be causing this error?

Code:
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int cube;
int number[4];

[Code] .....

View 6 Replies View Related

Visual C++ :: Number Of Players - Making Score Stay With Each Player

Oct 21, 2013

I am writing a game that is 2 to 4 players. i am wondering how to ask how many players, and make the score stay with each player. it is a rip off of zombie dice, this is what i have so far the playerScore array is to hold the score for each player and the turn array is hold hold the values that they rolled that turn, i also dont know how to clear out the turn array when it goes to the next player.

#include <iostream>
#include <cstdlib>
#include <cmath>
#include <ctime>
using namespace std;
int main() {
int playerScore[4];

[Code] ....

View 3 Replies View Related

C :: Create Labyrinth And Player Who Needs To Go Through The Map Collecting Objects

Jan 1, 2015

I actually need to create a labyrinth and a player who needs to go thru the map collecting objects (like bags, water etc...). I planned to do the map with a bidimentional array (5x5) but I dont know how to put different objects on an index.. Ex: array[3][2] will have a Botte of water and an energy bar..

Someone told me to use structs but I dont really understand how this would work... I've tried so many times bit I cant do it...

View 2 Replies View Related

C/C++ :: Create User Defined Dynamic Array For Player Scores - Missing Pointer Types Error

Jan 18, 2015

I'm completely new to pointers and have a homework assignment due where I'm supposed to create a user defined dynamic array for player scores. The only errors I'm experiencing is a C2109: subscript requires pointer type and only on the lines that use the int *score; variable (57, 62, 64, 69, 71, and 82). I've already tried adding = nullptr to the variable and that didn't work.

#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
void players(string[], int[], int);
void average(int[], int);

[Code] ....

View 3 Replies View Related

C :: How To Create A Structure That Pointing To Another Different Structure

Mar 17, 2013

how I can create a structure that pointing to another different structure. And also passing structure to function.

View 3 Replies View Related

C++ :: Create Structure To Hold Data For A Kennel

Apr 3, 2013

// This program creates a structure to hold data for a kennel

#include<iostream.h>
struct KennelList {
int dogID;
char gender;
int age;

[Code] ....

View 2 Replies View Related

C/C++ :: How To Create Objects Of Same Data Structure (type)

Dec 31, 2014

well i create a State.h class

#ifndef STATE.H
#define STATE_H
class State {
public:
virtual void handle_action() = 0;
virtual void update() = 0;
virtual void render() = 0;
};
#endif //STATE.H

What i'm trying to create is a simple State Manager for SFML! I created another class that inherits State.

#pragma once
#include "state.h"
class FirstState : public State {
public:
FirstState();
~FirstState();
void handle_action();
void update();
void render();
};

So the question is this, each state that i have will inherit the State class. However, i wanted to perhaps add each state object into a vector array. But i'm not sure as to what data type it be? I have a state manager class that will contain the vector.

What i want to do is this, each game state will create an object that will inherit functions from the state.h class. I want to store them all in a vector array, but each object is clearly named different. My curiosity was wondering, since all those different states inherit the State.h class, can i simply create a State Object std::vector<State> *states; that will contain all those different state objects?

[URL]....

View 1 Replies View Related

C++ :: Create A Vector Using A Structure Definition As The Basis?

Jan 25, 2013

I was trying to apply what is here (as someone who writes rarely and has to relearn everything each time): [URL] ....

I'm using a header file to define the structure:

#ifndef EINSTEIN_H
#define EINSTEIN_H
#include <stdio.h>
#include <vector>
struct SizeAll{
double year;
double R;
SizeAll() { year = 0; R = 0; }

[Code] ...

This creates quite a mess. It seems that somehow the "vector" declaration isn't working as the referenced web link seems to suggest that it should. I presume that, as usual, clearing one real error will eliminate the cascade of errors the first real error produces. Why won't VC++ accept the "vector" identifier?

The error messages that follow the build attempt are:

Friedman.cpp
d:documents and settingsxxmy documentsvisual studio 2010projectsfriedmanfriedmanEinstein.h(22):
warning C4996: 'fopen': This function or variable may be unsafe.
Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.

[Code] .....

View 14 Replies View Related

C++ :: How To Create Tree Data Structure With Boost

Oct 1, 2013

There seems to be lacking support for tree data structure. You have to implement it yourself?

View 2 Replies View Related

C :: Dynamically Create A New Memo Structure To Hold Memorized Fib

Jun 14, 2013

I need to dynamically create a new Memo structure to hold memorized fib #'s.I have two structures:

Code:

typedef struct HugeInteger
{
//array to hold the digits of a huge integer
int *digits;
//number of digits in the huge integer
int length;
}

[code]....

am having trouble with initializing the struct inside of the new Memo, I need the digit fields to null and the length field to 0 to indicate that F[i] has not yet been memoized...I have F->digits and F->length in the for loop but this just simply doesn't work..

View 2 Replies View Related

C :: Create A Structure To Store Information About Products For Sale

Apr 29, 2013

I am using Dev C++ compiler on Windows 7 and was programming a piece of code that is supposed to do the following -

Create a structure to store information about products for sale in a store. It should store information about the product name, the price, and the product number and then create an array of products called Inventory. Add five products to your inventory.

But for some reason, which is unknown to me, I always seem to get a compiler error. And this is what i have so far -

Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct product{
char name[30];
int product_number;
double price;

[Code] ....

View 4 Replies View Related

C++ :: Create A Class Type Structure Using Struct Instead Of Classes

Apr 16, 2013

I am trying to create a class type structure using struct instead of classes.

Code:
#include <iostream>
#include <stdlib.h>
using namespace std;
struct myclass {
int * array;
int nelements;

[Code] ....

Guess what I am asking is using the pointer in the first code section better or is there another way'. I don't know about making the second code work.

View 3 Replies View Related

C++ :: Use Class Structure To Create Program That Reads In Two Rational Numbers?

Nov 4, 2013

how to use a Class structure to create a program that reads in two rational numbers and adds them, subtracts, multiplies, and divides them.

View 3 Replies View Related

C/C++ :: Array To Only Print Out Final Average And Final Maximum Score With Final Minimum Score

Aug 27, 2014

#include <stdio.h>
float total, avg, max, min;
float judge[4];
int index;
int array[4];
int main() {
total = 0.0;
max = array[0];
min = array[0];

[Code] ....

I dont understand how to make the array when it prints out only print out the final average and the final maximum score with the final minimum score but what its doing at the moment is just giving an average for each individual score taken...

Minimum and maximum scores are displaying 0.0

And it displays these things 4 times in a row i just want it to be displayed once.

View 1 Replies View Related

C++ :: Creating Accounts And Stores It On CSV File

Jun 20, 2013

What I am trying to do is a small program that creates accounts (User name, age,...), and stores it on a CSV file. And later I can search for a user and edit some information about him (example, his age).

Here is my code:

#include <fstream>
#include <iostream>
#include <string>
#include <stdio.h>
#include <io.h>
#include <stdlib.h>
#include <string>

Looking at the "old code" ("void searchaccountold()"), I am sure the problem is on the "while" part ("while (myfile >> name >> age >> money)").

It should work, but it doesnt. I am almost sure the problem lies on the ";"... Because the CSV uses cells, and to pass to the second cell I would normaly need an ";" and in my case I have ">>". I have tryed to change them, to use getline, etc... and didnt work.

View 5 Replies View Related

C/C++ :: EEPROM Stores In Int To Char Convert

Jun 25, 2014

I am using eeprom my integer data store in that int =1234 it stores ony character in eeprom. one character is 12 and other one is 34

View 2 Replies View Related

C++ :: How To Make Array Which Stores Values From User

Sep 22, 2013

How to make an array which stores the values i'm getting from the users?

For example if i have a function which allows the user to give me values, how can i store them in an array.

View 4 Replies View Related

C++ :: Function That Stores Number Into Integer Array?

Apr 30, 2013

I'm writing a function that stores a number into an array. If the number is greater that the lowest number in the array then it replaces it. The array size is 10. When the number is stored in the array. The lowest number must then be remove.

View 3 Replies View Related

C++ :: While Statement - Calculate Total For Three Stores Payrolls

Mar 26, 2013

I have a program that needs to calculate the total for three stores payrolls.

Inputs would be the three stores payrolls
Output would be the total of all three

I HAVE to use the while statement.

I have also read the articles on the while statement on here and on other sites. I'm having trouble because every site I've seen so far has only been giving examples of numbers(like counting down or repeating a statement so many times).

Code:

#include <iostream>
#include <cmath>
using namespace std;
int main() {
//declare variables
int storePayroll = 0;
int totalPayroll = 0;
int storeNum = 0;

[Code] .....

View 6 Replies View Related

C++ :: Write A Program Which Stores 10 Decimal Numbers In Array

Sep 24, 2014

Write a program which stores 10 decimal numbers in an array. For these numbers accept input from the users. Once the array is populated do the followings:

Display each elements of the array
Display the sum of all the elements of array

View 4 Replies View Related

C Sharp :: Storing Positions Of DrawRectangle Into A List - Only Stores Last X And Y?

Oct 12, 2012

I am trying to store values of X and Y into a list like this:

if (pictureBox1.Image != null) {
                    draw = true;
                    Graphics g = Graphics.FromImage(imageFile);
                    Pen pen1 = new Pen(color, 4);
                    g.DrawRectangle(pen1, e.X - 3, e.Y - 2, 5, 5);

[Code] ....

It stores all the nodes but it stores them as the same position, I am not sure how to make them act independently.

View 2 Replies View Related

C++ :: Pass Object To Class Which Stores It In Container As Unique Pointer

Jul 24, 2013

class A (abstract)
class B : A
class C {
void add ( A(&*?) a )
std::vector<std::unique_ptr<A>> data; //unique_ptr<A> because A is abstract and therefore vector<A> isn't possible
}

upper situation. What is the best way to pass add an object of class B to C?

with C::add(A* a){ vector.push_back( unique_ptr<A>(a) ); }
and
int main() {
C c;
c.add( new B() );
}

This works, but i don't think it's very nice, because you could delete the pointer in main. What happens then with the unique_ptr? I could probably make C::add( std::unique_ptr<A> u_p ); but maybe it can be avoided that the "user" (in main() ) has to create the unique_ptr itself.

View 10 Replies View Related

Visual C++ :: Application Which Stores Information About People Along With Task List

Dec 19, 2012

Basically the question is to develop an application that allows: Create an application which stores information about people, along with a task list.

The user should be able to Store people's information

Name,
Age,
Telephone number,
Address

-Retrieve information by entering name
- Remove a person's record by entering their name
-Return records for all people, sorted according to an information type other than age
-Enter a task which needs doing, a priority entered for its urgency
-View highest priority task on the list
-User should be able to remove highest priority item on the list

How to develop this application on a console command line interface style or any other style.

View 2 Replies View Related

C++ :: Simple AI That Follows Player

Apr 10, 2014

I'm having some problems with implementing an AI. It should be just a simple AI that follows player. Here is the code that I got so far:

(float)DirectionX = Circle->GetX() - AI->GetX();
(float)DirectionY = Circle->GetY() - AI->GetY();

(float)Hyp = sqrt(DirectionX * DirectionX + DirectionY * DirectionY);

DirectionX /= Hyp;
DirectionY /= Hyp;

x += DirectionX * 3;
y += DirectionY * 3;

This is what I got so far. It creates a vector in a direction I want to move, then just normalizes the vector. Simple as that. But I'm having 2 problems..

AI moves towards player only when Im at like the end of screen and the AI is on the other side, I must keep a certain distance for it to be able to move towards me. Basically, its not constantly moving towards the player. I also tried it with trig, using atan2 for angle and sin / cos for speed. Also didn't work, same result.

The other problem is when I want to add i.e 5 more AIs. For each new AI it creates, it makes a new update.. So, to kinda clear it up. If I'm in middle of the screen and an AI is spawned above me, it will move towards me. But when after that one, 2nd AI spawns beneath me, both 1st and 2nd AI move up. Basically, previous AIs take the update from last one that is created. For updating I'm using lists, objects and iters.

View 3 Replies View Related

C# :: Three And Four Player Uno Game

Feb 26, 2015

I'm having some problems figuring out 3 and 4 player games in an Uno game I'm working on. I'm not sure what specifically the problem is, however. I've tried everything I can think of; I'm at a loss for what to do next. Two player games work perfectly, which makes the nonfunctional 3 and 4 player games seem odd to me. Here is the code:

public void MoveOpponents() {
if (nextPlayer == 0) {
if (Main.dir == Direction.Clockwise) nextPlayer = 1;
else nextPlayer = numPlayers - 1;

[Code] .....

The code for the human player is in Update(), but I won't show that because it's actually quite similar to the above code.

Right now what it's doing is jumping all over the place, making opponent 2 play before opponent 1, then I play, then opponent 1 plays. Then I play again. It's really messed up.

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved