// War Game made by Jeremy Wayman
 
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <string>
 
using namespace std;

int cardValue[13] = {1,2,3,4,5,6,7,8,9,10,11,12,13}; // Declaring first array
string cardType[4]; // Declaring second array
ifstream inFile; // Declaring a reading inFile
void displayRules(); // Declaring function displayRules
bool winner(int card1[], string type1[], int card2[], string type2[]); // Declaring function winner
void initialize();


int main()

{
	
	
	
	return 0;
};

bool winner(int card1[], string type1[], int card2[], string type2[]);
{


}

void displayRules()
{
	cout << "Welcome to the game of war!"
	     << "Your cards will be selected at random from \n "
	     << "a normal deck of cards. The symbols will \n "
	     << "be ranked in order of Hearts, Spades, Diamonds, "
	     << "and Clubs. You will be playing against a computer "
         << "opponent. ";
}

int cardValue();
{
	inFile.open("cards.txt");
	
	for(int i =0; i < 4; i++)
	cardType[i] = inFile.get();      //not sure about this inFile function
	
}

	
string convertCard(cardValue val[], cardType type[]);
{
	string temp;

	if (val[] == 11)
	return "jack";
	else if(val[] == 12)
	return "queen";
	else if(val[] == 13)
	return "king";
	else
	return val[];
}

So I am trying to make a war game. First of all I want to read in from a text file, I am reading in the values for an array. I need to use 2 arrays and I need input/output. I am trying to create a game of war that randomly picks cards for both players and then based on what you get is if you win or not.

How to read from the file depends on how the file was writte. Post a few lines so we can see what it looks like.

the text file is simply:

SPADES
HEARTS
CLUBS
DIAMONDS

Is that all there is to the file? What good does it do to list the four types of cards in the file without the quantity that the user holds.

all i want to do is read in those values and place then into a variable

Why? you don't need a file just to read those four strings -- hard-code them in your program because they will never change.

Yea but the whole point is that I want to practice reading in from a text file cuz i am unclear on how to do it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.