Clinton Portis 211 Practically a Posting Shark
#include iostream
using namespace std;

main()
{
     cout << "Q:  How many hookers does it take to screw in a light bulb?";
     cout << "\nA:  Go ask your mom.";
     return 0;
}
iamthwee commented: BRAVO! +11
Ancient Dragon commented: :) +26
Clinton Portis 211 Practically a Posting Shark

sry to make this so confusing. in need the function called updateCounter. and what it should do is to update the map to show if i have it the target or not. hope that was clearer.

Translation:

"I'm sorry to make this so confusing. I need to develop a function called, 'updateCounter.' It should update the map to show if I have hit the target or not."


It appears that you load a 2 dimensional array with ship positions. You should compare user input to the corresponding element of the array. If the element is occupied, then return hit, else return miss.

If hit, make a 'hit' assignment to the array, else update the array with a miss indication.

Redraw the array and prompt for next user guess.

Clinton Portis 211 Practically a Posting Shark

You are in charge of a high profile software design consulting firm. A customer bursts through the front door, comes running in flailing his arms wildly about, stops at your cubicle, looks you square in the eye and makes the following demand:

the ocean file has to be made separately by 15 by 15, but this is simple and i can do this. what i need help with is the update counter. which is i think to update the map. plese help me out!!!

Q: How do you respond...

Clinton Portis 211 Practically a Posting Shark

Many have recommended the curl library for applications that need to interface with the net.

Clinton Portis 211 Practically a Posting Shark

I thought this website on coding conventions was pretty cool.. learned some things that I never knew before:

http://www.possibility.com/Cpp/CppCodingStandard.html#init

I was just wondering:

If there are any conventions in particular you agree or disagree with (and why)

If this would be worthy of being a 'sticky post' as I think a lot of new coders would gain valuable knowledge from learning modern coding conventions.

One topic, for example, that I never considered were the possible issues associated with throwing exceptions inside of a destructor.

Another involves the coding out large blocks of code:

You can't use /**/ style comments because comments can't contain comments and surely a large block of your code will contain a comment, won't it?

If there was something of interest you weren't aware of before reading, please share.

Clinton Portis 211 Practically a Posting Shark

Since you are declaring 'p' locally from within the function, it will be destroyed with the function.. just as any locally declared function variable.

Additionally, you declare 'p' and it is never assigned anything. Later in your function you attempt to dereferrence a NULL pointer.

So the answer is, to declare a gobal variable named 'p' inside of int main() that you can pass into all your functions.

Clinton Portis 211 Practically a Posting Shark

Could it be possible for me to read the file name as a string, and add the extension ".output" to the string, and then convert it back to an array of chars?

I'm glad you mentioned this. String class objects are very versitle and can handle virtually any input the user might throw at you.

If we look at the open() function from <fstream>, we see that it has a const char* (cstring) parameter as it's first argument.. which is the file name in a cstring:

fstream::open

public member function

void open ( const char * filename, ios_base::openmode mode = ios_base::in | ios_base::out );

But we are using a string.. what are we supposed to do? Luckily, there is a <string> class member function called c_str() which returns a cstring pointer:

const char* c_str ( ) const;

Get C string equivalent
Generates a null-terminated sequence of characters (c-string) with the same content as the string object and returns it as a pointer to an array of characters.

A terminating null character is automatically appended.

Knowing all this, we can take all user input in the form of a string, concantinate the string with the required file identifier (.txt) and pass the string into the open() function by calling the c_str() member:

#include<string>

string name;

cout << "Enter file name: ";
cin >> name;

//Check to see if user already appended the file type
if(name.find(".txt") == string::npos)
{
    //If user did not add file …
Darkmist commented: The example on c_str() was really clear and easy to understand +0
Clinton Portis 211 Practically a Posting Shark

You have ye'self a good workin' program up there.. just had to make 2 minor changes:

//this
coin = 1 +rand()%2;
//should be this:
coin = 1 +rand()%3;

//this
int money = head - tail;
//should be this:
int money = won - tail;
Clinton Portis 211 Practically a Posting Shark

I wish you luck on your endeavors.

Clinton Portis 211 Practically a Posting Shark

Steps #1 through #9 are complete. Aside from the required error handling, the bulk of your project is complete.

Perhaps we could come up with a couple of functions to test user input for validity. If invalid, throw an error; catch error and respond appropriately.

But since I am tired as heck, I am about do like my programs and crash.

Nick Evan commented: You derserve rep for this monster thread. +11
jonsca commented: nuff said +1
Clinton Portis 211 Practically a Posting Shark

Here is recent help given to one of your classmates:

http://www.daniweb.com/forums/post1070744.html#post1070744

trcartmill commented: Thank you, That helps me out on the right track. but im getting errors in the compiler that is: could not deduce template argument and expects 2 arguments, 3 provided. it would be line 8 in your code. +0
Clinton Portis 211 Practically a Posting Shark

int main(){return 0;}

Clinton Portis 211 Practically a Posting Shark

Also, why are you posting C code in a C++ forum..??!

Clinton Portis 211 Practically a Posting Shark

I found this article at msdn:

The multiplicative operators take operands of arithmetic types. The modulus operator (%) has a stricter requirement in that its operands must be of integral type. (To get the remainder of a floating-point division, use the run-time function, fmod.) The conversions covered in Arithmetic Conversions are applied to the operands, and the result is of the converted type.

According to the article, you might have better luck using the fmod() function from <cmath>.

Clinton Portis 211 Practically a Posting Shark

You seem to have mentioned that you have attepted to make some sort of effort at seeking a solution to the problem. I'm sure myself and others would be highly interested in seeing what you have come up with thus far; thereby seperating yourself from the masses of "please do this for me" laziness that we are so often subjected to on a daily basis.

mrnutty commented: Indeed. +2
Clinton Portis 211 Practically a Posting Shark

You may want to check this out before posting homework.

Clinton Portis 211 Practically a Posting Shark

I have to read 16 bytes using the low-level function call read() (in C). After I read the first 16 bytes, the next time I need to read from the same file, I'll only have to read it from until the point it was read before..

Since you only require to read in a certain amount of the file (as opposed to reading in the entire file at once) I think readsome() function may be a more appropriate choice:

istream::readsome

public member function

streamsize readsome ( char* s, streamsize n );

Read block of data available in the buffer
Reads a block of data of up to n characters and stores it in the array pointed by s, but unlike member function read, readsome stops reading if the memory buffer associated with the stream runs out of characters, even if the End-Of-File has not yet been reached.

Return Value
The number of characters extracted.

Errors are signaled by modifying the internal state flags.

With this in mind, I would propose using the readsome() function and reading the file into a char[16] buffers (or char[17] if you would like to provide null termination which will allow you to use <cstring> functions safely)

Since you would probably need to use several char[16] buffers, let's create a bunch of them:

char buffer[100][16];

A more optimal alternative of course, would be to dynamically create an array of specific size based on the number of characters in your file:

halluc1nati0n commented: Good ideas.. +1
Clinton Portis 211 Practically a Posting Shark

laugh out loud :D

How about this:

for(int i=0; i==0; i=0)
    for(int j=0; j<1; j++)
          cout << "M";

OP: you might want to check this out before you continue to act a fool up in here.

Clinton Portis 211 Practically a Posting Shark

try this string parsing algorithm to split your line up into individual strings:

#include<string>
#include<vector>

int prev = 0;
int curr = 0;
string temp;
string line = "The man is 67 years old and driving an Oldsmobile Rocket 88";
vector<string> vstring;

do{
     prev = curr;
     curr = line.find(' ');

     if(curr == string::npos)
          temp = line.substr(prev);
     else     
          temp = line.substr(prev, curr-1);

     vstring.push_back(temp);
     
  }while(curr != string::npos);

Now you can just test elements of the vstring vector to get what you want:

string word;

cout << "Enter word to find: ";
cin >> word;

for(int i=0, size=vstring.size(); i<=size; i++)
{
     if(word == vstring[i])
          break;
}

if(i == size)
     cout << "word not found";

else
     cout << word << " found at element " vstring[i];
iamthwee commented: It's pi +11
Clinton Portis 211 Practically a Posting Shark

Unfortunately in c++, there is really no good way go locate lines in your file without reading the entire file 'character at a time.'

So, if you have to read only a single line from a file, we know we are at some point going to have to be inefficient... so let's only be inefficient once. The following code traverses the entire file once, char at a time, but saves the positions of all '\n' new lines... so any queries for specific lines from the file can be made efficiently:

#include<iostream>
#include<cctype>
#include<fstream>
#include<string>
#include<vector>

using namespace std;

int main()
{
    int linecount = 0;
    int linetoget = 0;
    int pos = 0;
    char c = '\0';
    char again = '\0';
    string line_str;
    vector<int> linepos;
    ifstream infile;

//Be sure to open in binary mode when messing about with file pointers    
infile.open("C:\\Users\\Dave\\Documents\\resume.txt", ios::binary);

    if(!infile.is_open())
    {
        cout << "\a\nError opening file!";
        cin.get();
        exit(1);
    }

    //Set first line position
    linepos.push_back(0);
    linecount++;

    //Populate line positions from the rest of file
    //This part sucks, but we only have to do it once.
    do{
        infile.get(c);
        if(c == '\n')
        {
            pos = infile.tellg();
            linepos.push_back(pos);
            linecount++;
        }
    }while(infile.good());

    //Reset error flags from the failing good() condition
    infile.clear();

    do{
        do{
            cout << "\nEnter line of file to get: ";
            cin >> linetoget;

            if(linetoget < 1 || linetoget > linecount)
            {
                cout << "\a\nOut of Range.  Please select line number 0 to " << linecount << endl;
            }
        }while(linetoget < 1 || linetoget > linecount);

        infile.seekg(linepos[linetoget-1], ios::beg);
        getline(infile, …
Clinton Portis 211 Practically a Posting Shark

Here is one possible way:

int i = 0;
int line = 0;
int number = 0;
char c = '\0';
string temp;

//Make sure your file is opened in binary mode when manipulating file pointers
infile.open("C:\\Documents\\test.txt", ifstream::binary);

cout << "Enter line number to read from file: ";
cin >> number;

//Search character by character for new line
//Increment counter when "new lines" are found.
do{
     infile.get(c);
     i++;
     if(c == '\n')
          line++;
     }while(line != number && infile.good());

//Set 'get' ponter to beginning of desired line to read
infile.seekg((i+1), ios:beg);

//Get the line.
getline(infile, temp);

Like ancient dragon says, there is no real automatic way to find where you want to be in the file without reading your way through it. Unless you already no exactly how many characters each line contain, and they all will always contain the same about of characters at all times, then you can just seekg() to the specific line.. but this is a very rare case.

nunchuckie commented: educational helpful +1
Clinton Portis 211 Practically a Posting Shark

I find the concept of polymorphism (inheritance) to be a quite interesting topic.. although I am by no means an expert in this (I just do enough of this to get by) I believe it is a powerful OOP concept and in my opinion, is probably the main construct that defines OOP languages.

class women
{
     //Attributes common to all women
     //functions common to all women
};

class blondes : public women
{
     //Now you get all the womanly stuff
     //plus 'blonde' attributes and behaviors
};

class brunetts : public women
{
     //Brown hair
     //Nice rear end
     // etc etc...
};
Clinton Portis 211 Practically a Posting Shark

People always ask, "Why do you always have to initialize your variables?"

This is why:

//Here you create something.  It is never initialized; therefore probably contains some sort of value..   what exactly it contains, we don't know.

long double points;

So when you start using this varible for accumulation, you are just adding to an unknown value:

points += 100;

Usually one would use a simple = assignment to initialize a variable, but since your variable is part of a class, it can only be initialize via use of a class constructor:

class games
{  
     public:

     games();
     long double points;   
     int tictactoe(void);    
};

games::games()
{
     points = 0.0;
}

Now, everytime a 'game' object is created, it's contents will automatically be initialized. You can then safely add your points to it and recieve expected results.

Lesson of the day: Take the time to initialize EVERYTHING.. ALL THE TIME. Then you will always get expected performance.

mrnutty commented: Exactly, many problems comes from un-initialized variables! +2
Clinton Portis 211 Practically a Posting Shark

By doing this, you have established a direct relationship between the two arrays:

//We can assume that 'votes[3]' corrosponds to 'candidates[3]', for example.
if ( inFile >> candidates[i] >> votes[i] )

So all you really need to do is extract the largest value from the votes[] array:

int index = 0;
int max = 0;

for(int i=0; i<6; i++)
{
     if(votes[i] > max)
     {
          max = votes[i];
          index = i;         
     }
}

cout << "The winner is " << candidates[index] << " with a winning vote count of " << votes[index];
Clinton Portis 211 Practically a Posting Shark
//This
char * DecData = new char (stringlen+1);
//Should be this:
char* DecData = new char[(stringlen+1)];

//This
int * NewData = new int (strlen(Data));
//Should be this:
int* NewData = new int[(strlen(Data))];
Clinton Portis 211 Practically a Posting Shark
//attempting to initialize with an uninitialized value out of bounds of the array
int numOfStudents[100] = students;

//function name spelled wrong
acceptScores (numOfStudents);

//Here you try to pass an array pointer to a function prototyped to accept an int
acceptedScores (numOfStudents);

//You should dereference the pointer to an int using an array subscript
acceptedScores (numOfStudents[1]);

//The function definition:  the function name is spelled wrong/does not match it's prototype.  Additionally, you lack a starting { curley brace to start the block of code.  
void acceptScores(int numOfStudents)

//All these 'for' statements should be 'if'
//also, you can't have a ; semicolon after an if() condition
//also, you create a variable 'scores' but never assign anything to it.
for (scores >= 80);

//You cannot 'return' anything in a void function()
//Even if you could, you can only return one item 
return A, B, C, D, E;

//missing semicolon in printedscores() function
int students

//variable not declared inside of printedscores()
scores

//incorrect for loop condition
//should be something like for(int grade=0; grade<=students; grade++)
for (grade = 0; grade)
Clinton Portis 211 Practically a Posting Shark

A lot of people have questions about how to load a text file using file I/O. There seems to be 2 popular methods to loading a text file:

Use fstream's >> extraction operator. Simple enough, load the file directly into individual containers, word at a time, but you lose your delimiting white spaces (assuming you need them). So some file integrity is lost, unless you make the effort re-construct the file by re-inserting all the white spaces.

So instead, you decide to use getline(). You preserve all white spaces and load the file line by line... but now you have to parse a line of data into individual substrings; either by using <string> member functions, performing string[] array operations, or using strtok().

One alternative I would like to suggest: why not do both? It is possible to read a file in it's entirety and read in text 'word at a time' into individual containers.. without having to do any string parsing:

#include<string>

//Be sure to open your file in binary mode
infile.open("C:\\Users\\Dave\\Documents\\test.txt", ifstream::binary);

//Here you can load the file in it's entirety    
while(getline(infile, lines[i]))
{
     //Go back to the start of the line
     infile.seekg(begin, ios::beg);

     //Now you can load the same data into individual containers
     for(int j=0; j<4; j++)
     {
          infile >> words[word_count];
          word_count++;
     }

     //Discard any extra characters left behind
     infile.ignore(100, '\n');

     //Save current position, so you can go back to the beginning of next line
     begin = infile.tellg();

     i++;
 }

So now you have …

Clinton Portis 211 Practically a Posting Shark

Anyone please feel free to chime in if you see anything wrong here:

//line #11
if(Temp -> Ch [B]=[/B] CharToDelete)
Clinton Portis 211 Practically a Posting Shark

Another good ol' database program. This calls for 'an array of structs'

create your data type:

struct record
{
     string description;
     int product_number;
     double unit;
     int sold;
};

Now that you have designed your object, you need to create a bunch of them:

record database[100];

One of your menu options should provide a function to populate your objects... whenever the user wishes to add to the database:

do{

     cout << "Enter product description: ";
     cin >> database[i].description;

     cout << "Enter product number:  ";
     cin >> database[i].product_number;
     ...
     ...
     etc. etc.

     i++;

}while(another == 'y' || another == 'Y');

You also have the ability to search your array of structs:

//this will return the element position of the found record in database (if not found, return -1)
int find_by_sales(record database[], int sold_target, int entries_made)
{
     int i=0;

     while(database[i].sold != sold_target && i <= entries_made)
     {
          i++;
     }

     if(i == entries_made)

          return -1;

     else

          return i;
}

You can have similar functions to perform sorting as well, where you can sort the database[] array based on a single attribute.

Here is an easy way to sort the database[] array based on a single attribute (in this case, we'll use sales) using the sort() function from <algorithm>

#include<algorithm>

bool sales_test(record& i,  record& j){return (i.sold < j.sold);}

sort(&database[0], &database[entries], sales_test);

You can also have a menu option that will display the entire database contents:

void display_database(record database[], int entries_made)
{
     for(int i=0; i<entries_made; i++) …
Clinton Portis 211 Practically a Posting Shark

Do you like long walks on the beach

Clinton Portis 211 Practically a Posting Shark

You are right on brother.

One suggestion: whenever you see a self re-assignment, you should have "compound operator" runnin' through your noggin'

y = y + 1;

//is the same thing as

y += 1;  //The += operator signifies "accumulation"

It's such a common task to re-assign a value to the original variable, that c++ made these compound operators available to you:

y = y / x;     y /= x;
y = y * x;     y *= x;
y = y - x;     y -= x;
y = y + x;     y += x;
y = y % x;     y %= x;

for (i = 0; i<=6;  i+=3)
for (j = 0; j<=15; j+=5)
kvprajapati commented: helpful! +6
Clinton Portis 211 Practically a Posting Shark

Here is a possible pseudo-code for what ye' wish to accomplish:

1. Prompt the user for 5 numbers:

do{  
     cout << "Enter a number: ";  
     cin >> user_picks[i];
     i++;
}while(i<5);

2. Ensure that user did not make a duplicate pick:

do{  
     cout << "Enter a number: ";  
     cin >> user_picks[i];
     //You will design the is_duplicate() function
     if(is_duplicate(user_picks[i]))
     {
          cout << "\aError!  Number already used!";
          i--;
     }
     i++;
}while(i<5);

3. Generate 5 random non-duplicated numbers:

//Seed random number generator
srand(time(NULL));

//Populate lotto[5] array with 5 unique integers
for(int i=0; i<5; i++)
{
     lotto[i] = rand()%55+1;
     
     //You will design the is_duplicate() test 
     if(is_duplicate(lotto[i]))
     {
          i--;
     }
}

4. Compare the user_picks[5] array with the lotto[5] array:

for(int i=0; i<5; i++)
{
     for(int j=0; j<5; j++)
     {
          if(user_picks[i] == lotto[j])
          {
               match++;
          }
     }
}

5. Display useful information to the user:

cout << "Your numbers: ";
for(int i=0; i<5; i++)
{
     cout << user_picks[i] << ' ';
}

cout << "Official lottery drawing: ";
for(int i=0; i<5; i++)
{
     cout << lotto[i] << ' ';
}

cout << "You have successfully matched " << matches << " numbers!";

I have just spoon fed you a lot of useful information that no one else would give you without any effort or attempt at programming on your part so I suggest you take this pseudo-code and run with it.

Clinton Portis 211 Practically a Posting Shark

Although I am by no means a network administrator, this assignment doesn't really seem that overly complex...

Here is how one can determine the IP class:

Class A: Class A addresses are specified to networks with large number of total hosts. Class A allows for 126 networks by using the first octet for the network ID. The first bit in this octet, is always set and fixed to zero. And next seven bits in the octet is all set to one, which then complete network ID. The 24 bits in the remaining octets represent the hosts ID, allowing 126 networks and approximately 17 million hosts per network. Class A network number values begin at 1 and end at 127.

Class B: Class B addresses are specified to medium to large sized of networks. Class B allows for 16,384 networks by using the first two octets for the network ID. The two bits in the first octet are always set and fixed to 1 0. The remaining 6 bits, together with the next octet, complete network ID. The 16 bits in the third and fourth octet represent host ID, allowing for approximately 65,000 hosts per network. Class B network number values begin at 128 and end at 191.

Class C: Class C addresses are used in small local area networks (LANs). Class C allows for approximately 2 million networks by using the first three octets for the network ID. In class C address three bits are always set …

Clinton Portis 211 Practically a Posting Shark

- BOTH HEADER FILES AND RELATED FUNCTIONS: I changed over my char arrays to strings (the project calls for maximums of characters). How do I easily change these over?

This doesn't seem like it would be that big of a deal. Change the header from <cstring> to <string>. Anytime you want to compare string objects use == instead of strcmp(), anytime you want to assign stuff to your string, use the assignment operator = instead of strcpy(), anytime you want to add to a string, use += instead of strcat(), etc, etc.

- ROSTERAPP.CPP: in displayStudent I have a comment for the loop if the entered number is found, but sometimes I get a FC. What am I doing wrong?

The success of this test depends on getID() to return non-zero "TRUE" if studentID exists, or return 0 "FALSE" if studentID has not been populated:

if (stu[id].getID() == false) //WORKING, but not the way it should... causes an FC error

As of right now, whenever a 'Student' object is created, none of the private variables are ever initialized.. so even if you create a new 'student' object, there is no guarantee that studentID will be zero (false), even though it has not been assigned anything. To make sure studentID is zero whenever new 'student' objects are created, we will make a simple default constructor. This is a function that will automatically get called every time a new 'student' object is created. We can use this feature to initialize …

Clinton Portis 211 Practically a Posting Shark

Just do the opposite of what you are doing and it will rotate your 'cube' in the other direction.

Clinton Portis 211 Practically a Posting Shark

Why is C++ so big?

That's what she said.

Clinton Portis 211 Practically a Posting Shark

Of course you can always perform array operations on your string if you are not comfortable with using string class members:

#include<cctype>

string expression = "5+104-32/5";
string operators[10];
string terms[20];
int term_counter=0;
int op_counter=0;

for(int i=0; i<expression.size(); i++)
{
     if(expression[i] == '+' || expression[i] == '-' ||
        expression[i] == '*' || expression[i] == '/')
     {
          //extract all operators (in sequential order)
          operators[op_counter] = expresssion[i];
          op_counter++;
          term_counter++;
     }
     else if(isdigit(expression[i]))
     {
          //Extract terms into individial 'string' containers
          terms[term_counter] += expression[i];          
     }             
}

also i have to make a simlple calculator.. with only one operation at a time.. i.e only 5+4 at a time and not 5+4*3 bcoz dat will involve precedence rules...

All of the above code will work for what you are asking.

snehil_khanor commented: thnx :) +1
Clinton Portis 211 Practically a Posting Shark

This is a common mistake whilst performing tests using boolean logic; there is a distinct difference between the '=' assignment operator and the '==' equality test. (the '=' assignment operator should never be used to perform boolean tests)

Clinton Portis 211 Practically a Posting Shark

jst m not able to think how to exrtract data from string..

We can use our standard string parsing algorithm. In this case, we can use find_first_of() since we will have multiple delimeters (+, -, *, and / for example)

string expression = "5+104-32/5";
string terms[20];
int prev=-1, curr=-1; 

while(curr_pos != string::npos)
{     
     prev_pos = curr_pos;     
     curr_pos = find_first_of("+-*/", prev_pos+1);      

     if(curr_pos != string::npos)           

          terms[i] = expression.substr(prev_pos+1, (curr_pos - prev_pos)); 
}

You can learn about other <string> class member here that will help you with your parsing needs.

Hope this helps to point ye' in the right direction. This is a basic string parsing algorithm for <string> class objects. This is untested code and may contain easy to fix errors.

Clinton Portis 211 Practically a Posting Shark

how do i get the average of average?

add up all the tests and divide by the total number of tests.

Clinton Portis 211 Practically a Posting Shark

I have a feeling you may have place program output inside of a loop.

Let us see ye' code.

Clinton Portis 211 Practically a Posting Shark
b = static_cast(a);

should be:

b = static_cast<int>(a);
Clinton Portis 211 Practically a Posting Shark
int counter=0;

while(...)
{
     ...
     ...
     ...
    counter++
}

cout << "The while() loop executed " << counter << " times.";
Clinton Portis 211 Practically a Posting Shark

i am in need to change my char to int.

You are in luck.. char to int conversions are wicked easy..

(and so is any conversion among c++ standard primitive data types)

Most people like to use the old c-style cast because it's quick and easy although technically it's not c++:

char a = 'A';
int b;

// b will contain the numerical ascii value of capital letter 'A'
b = (int)a;

Now here is the technically correct c++ method:

char a = 'A';
int b;

b = static_cast<int>(a);
Clinton Portis 211 Practically a Posting Shark

I just want to say that the deque class reminds me of Dairy Queen teehee.

Clinton Portis 211 Practically a Posting Shark

This may or may not be part of the problem, but it needs to be adressed:

if(player_card2 == 10|11|12|13)

I did the same thing when I was first learning boolean logic and performing tests, and it took me a long time to understand why things are the way they are, but for now just trust me.... you would think the above is correct, but there is a specific way that boolean tests are handled, either in a singular expression, or a stand-alone variable (which yeilds true or false, non-zero and zero respectively)

if(player_card == 10 || player_card == 11 || player_card == 12
        player_card == 13)

     //or in a simplified version:

     if(player_card2 > 9 && player_card < 14)

     //or

     if(player_card >= 10 && player_card <= 13)

So, keep in mind, boolean logic is handled individually per expression, or as a stand alone TRUE/FALSE flag.

spookyfish commented: Helped me solve my problem really quickly! +0
Clinton Portis 211 Practically a Posting Shark

I believe our friend adrianwx has addressed these issues in his cool DOS console tutorial: http://www.adrianxw.dk/index.html

Clinton Portis 211 Practically a Posting Shark

finding and storing the relevant line number the string was located at on the file in the token objects.

If I understand you correctly, you seem to be in need of keeping track of what line you are at whilst reading from a .txt file.

So, I will suggest a way to keep track of what line ye' are reading from.

It looks like you are >> streaming in single words at a time from the .txt file... I would suggest using the<string> class function called getline() instead, so you can keep a counter associated with how many times ye' have called getline() and thusly know which line ye' are on.

This is what you have:

while( inFile.peek() != EOF )
{

     inFile >> tokens[ tempx ].tokenString;

     tempx++;

}

Try changing to this:

int tempx = 0;

while(getline(infile, tokens[ tempx ].tokenString))
{    
     //Here 'tempx' can also be your "line counter"
     tempx++;
}

Now you have tempx as a line counter, refer to it as necessary to determine what line ye' are on.

But I bet you are asking yourself, "that's great clinton portis.. but now my token array contains entire lines instead of individual words."

So, to get around this, you can use <string> member functions to return individual words from your array (such as find(), find_first of(), and substr()). Or you can perform array operations on your token array to extract individual words. you could use strtok() (if …

Clinton Portis 211 Practically a Posting Shark

This guy can do some amazing stuff with the DOS console window.. best tutorial I've seen for become a master of the console:

http://www.adrianxw.dk/index.html

I think you'd be interested in, "Win32 Console Applications - Part 6"
http://www.adrianxw.dk/SoftwareSite/Consoles/Consoles6.html

Clinton Portis 211 Practically a Posting Shark
cout << "The total is: " << x;