Clinton Portis 211 Practically a Posting Shark

Minor error, here is the updated code:

while(tokens[i] != NULL)
{
     //Let's turn this <string> into a c-string so strtok() will be happy teehee
     tokens[i] = strtok(input.c_str(), delimeters);

     i++;
}

excerpt about strkok(): "This end of the token is automatically replaced by a null-character by the function, and the beginning of the token is returned by the function."

If I forced the loop with .size() it would have made strtok() work more times than it had to and would have ran off the end of the c-string char array.

Clinton Portis 211 Practically a Posting Shark

The big thing I'm missing here is the correct way to parse a string and turn the values into... an array of variables? Or something more efficient I'm not even thinking of?

Very good observation, parsing your file-string into an array of substrings. Yes, there is also a way to turn those strings into numbers you can use to perform math calculations.

First, let's talk about parsing a <string> class object.

I have recently posted an in-depth method to parsing strings using the strtok() function from <cstring>, but since we are using <string> class objects, let's benefit from the cool stuff that comes with string objects.

Here is a list of all the stuff packed inside of a string.

Here is my favorite way to get individual stuff out of a string. I like to go right to the find_first_of() string member.

As you can see, find_first_of() is well overloaded to fit your needs.

size_t find_first_of ( const string& str, size_t pos = 0 ) const;
size_t find_first_of ( const char* s, size_t pos, size_t n ) const;
size_t find_first_of ( const char* s, size_t pos = 0 ) const;
size_t find_first_of ( char c, size_t pos = 0 ) const;

The version I like to use above is in green. Simply supply a char and tell it where to start (or resume) in your traversal through the source string. I like using find_first_of() because you can use …

Clinton Portis 211 Practically a Posting Shark

oh, didn't see you need to round off to 2 decimal places....

setpricision is the way to go then.

Clinton Portis 211 Practically a Posting Shark

Ye' can still ask all your questions at once and still be able to accept user input individually:

cout << "What type of ice cream...? ";
cout << "\nWhat kind of topping...?";
cout << "\nSprinkles bueno? (si o no)";

cin >> ice_cream >> topping >> sprinkles;

Just like you can chain together output to the console, you can chain input from the user.

If you still would like a class on parsing strings into substrings.. lemme know.

Go redskins.

Clinton Portis 211 Practically a Posting Shark

You are using getline() to obtain an entire line of user input and storing that input into a <string> object called 'order'

You are then attempting to use boolean logic to test 'order' to test an entire line of user input that may contain several answers to the prompted questions asked by ye' program.

//Here you essentially ask the user 3 questions at once in which he/she has to reply to all 3 before hitting the [Enter] key:

if (icecream == "")            

     cout << "Do you want chocolate, vanilla, or twist?" << endl;        

if (sauce == "")            

     cout << "Hot fudge, chocolate or strawberry sauce?" << endl;        

if (sprinkles == "")            

     cout << "Do you want sprinkles (yes/no)?" << endl;

Here, getline() will have to accept all 3 answers to the above questions... all at once:

getline(cin, order);

So at this point, you have a string that probably looks like this: "chocolate hot fudge no", which is all of your answers in one string.

And now you are attempting to test 'order'; however, 'order' will never satisfy any of the tests.. because it holds 3 answers. All your boolean tests attempt to test one answer at a time:

//At this point, order would look something like this:
// "chocolate hot fudge yes" which will never satisfy any of your tests:

//No dice
if ((order == "chocolate") || (order == "vanilla") || (order == "twist"))

//Won't work
if ((order == "hot fudge") || (order == "chocolate") …
Clinton Portis 211 Practically a Posting Shark

ispunct() may not be specifically what you are looking for to split up the string into tokens.. but I would suggest strtok()

char * strtok ( char * str, const char * delimiters );

as you can see, strtok() accepts 2 arguments, the first being a c-string (char array) that you want to be tokenized; the second argument is another c-string that you populated with delimeters (any character that will signify the end of your token, such as a ' ' white space or a '.' period.. could be anything you want) The function will return a pointer to the first character of the token whenever it hits one of the delimeters. (which we will save into an array of char* pointers in the example below)

So put strtok() in a loop and let it fly.. it will return *char pointers to every token in the string that you supply whenever it detects of your delimeting characters.

I see that in your code you are using <string> class variables.. which is fine, but remember, strtok() is looking for a c-string char array.. not a <string> class object. Luckily, string objects contain a member function that will return a c-string pointer:

#include<cstring>

string input = "This is a sample string.";
char delimeters[3] = {'/', '\n', ' '};

//Dynamic array (of 'char' pointers that will contain the address of each token)
char **tokens = new char*[80];

int i=0;
while(i < input.size())
{
     //Let's turn this <string> into a …
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

Let me see some of that sweet lovin' code..

Clinton Portis 211 Practically a Posting Shark

Good news.. the solution to your problem is wicked simple.

May I recommend the ceil() and floor() functions of the <cmath> library.

Clinton Portis 211 Practically a Posting Shark

i have to read each line and then copy to a variable.

Perhaps strtok() may not be the best way to handle this situation (although I guess it can be used using the '\n' newline escape character as a delimeter); however, your goal seems to be to read in 1 line at a time, so I will suggest the <string> class function known as getline().

use getline() to extract single lines at a time from (in this case) your .txt file. Here is an example:

(oh yeah, since you posted in the c++ forum, you'll get ye' answer in c++)

#include<fstream>
#include<string>
...
...
...
ifstream infile;
string line_of_text, entire_document;
....
....
while(getline(infile,  line_of_text))
{
     entire_document += line_of_text;
}

So there ye' have it. The code reads in line-at-a-time and concantinates the line of text to another string object (entire_document) which will eventually hold the contents of the entire .txt file. Hope you can translate this to C.

strtok() is mostly used for parsing up individual c-string into sub c-strings.. but can also have applications with regular strings (not the preferred method, but can be done.)

Clinton Portis 211 Practically a Posting Shark

Why are you returning 0 from your 'else' conditions..?? why not let processing continue throughout the loop?

Stuff like this can cause your program to not work the way you think it will work.

Clinton Portis 211 Practically a Posting Shark
int *x = new int;
int y;

cout << "X address is:  " << x ;
cout << "\n\nY address is:  " << &y ;

delete x;

The first method (x) you are reading from a pointer without dereferencing it.

The second method (y) you are using the address operator to return the address of the variable.

Clinton Portis 211 Practically a Posting Shark

Looks like you are attempting to sendmessage() to your listbox upon reciept of WM_PAINT messages.... and the only time I think your program will get a WM_PAINT is when you invalidate_rect() inside of your WM_COMMAND... So my question is: what is going to trigger the appropriate WM_COMMAND?

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

I guess you can only compare what you have... right?

Therefore, list traversal w/ comparison should only be as long as your shortest list.

Another option could be to populate the shortest list with a sentinal value so that both lists would be of the same length.

Clinton Portis 211 Practically a Posting Shark

Is merging the 2 lists into a 3rd list an option for you?

Clinton Portis 211 Practically a Posting Shark

Q: are you allowed to use the atof( ) function? (part of the <cstdlib> library)

Q: are you allowd to use the <sstream> library?

If not, it would take some pretty decent math power to turn a c-string into a float.. perhaps the math would be less intense isolating the first digit of a float... but what if the first digit input by the user was not actually a digit, thus throwing the input stream into utter chaos...

Clinton Portis 211 Practically a Posting Shark
void draw_circle()
{     
     for(int i=0; i<80; i++)     
     {          
          outtextxy(point[i].x, point[i].y);
          cout << '*';
     }
}
Clinton Portis 211 Practically a Posting Shark
#include <iostream>
using namespace std;

double calculatecharges(double);

int main(int argc, char *argv[])
{
     //Syntax Error Here
     //double hours; rate;

     double hours, rate;
     int x = 0;

     do 
     { 

          cout<<"Enter number of hours parked: ";
          cin>> hours;

          rate = calculatecharges(double hours);

          cout<< " your parking fee is :" << rate << endl;

          x++;

      }while(x < 4); 

     system("PAUSE");

return EXIT_SUCCESS;
}


//Syntax Error Here
//Only function prototypes get a semicolon
//double calculatecharges(double hours) ;

double calculatecharges(double hours) 
{
     double base_rate = 2;
     double long_rate = .50;
     double max_rate= 10;

     if (hours>3)

          rate=base_rate;

     else if (hours>3)

          rate=((hours-3)*long_rate + base_rate);

     else (hours>11)

          rate = max_rate;
}
Clinton Portis 211 Practically a Posting Shark

Your professor says you have to accept user input as a floating point number, but he has no requirement for storing the variable as a float; therefore, I would simply accept all user input into a c-string (char array) and perform your validation. The following code uses isdigit() from the <cctype> library:

char user_input[100];

cout << "Enter a floating decimal number:  ";
cin >> user_input;

if(isdigit(user_input[0])
{
     cout << "\n\nValidation Correct. ";
}
else
{
     cout << "\n\n\aInvalid Float.  ";
}
Clinton Portis 211 Practically a Posting Shark

Your professor gave you a function free of charge called outtextxy( ). Worst case scenario, why not just call outtextxy() individually for every ascii character that you will to output on the dos console to draw your circle?

This may seem inefficient, but here is a way to at least make your code look 'better':

struct coord{
   
     int x;
     int y;
};

void draw_circle();

     coord point[80];
     

     //This is where it sucks..  it's up to you to come up with this list of coordinates 
     //through trial-and-error.
     point[0].x = 10; point[0].y = 15;
     point[1].x = 11; point[1].y = 14;
     point[2].x = 12; point[2].y = 14;
     point[3].x = 13; point[3].y = 13;
     point[4].x = 14; point[4].y = 13;
     ...
     ...
     ...
     point[79].x = 9; point[79].y = 16;


void draw_circle()
{
     for(int i=0; i<80; i++)
     {
          outtextxy(point[i].x, point[i].y);
     }
}

Although this looks brutally painful, I believe this is an appropriate technique for your level of academics. This will involve a lot of trial-and-error (having to recompile and run your program after every 'guess' of where to plot the next point for your circle) but after you've done the hard part of getting all those coordinate positions, the rest is easy.

One thing that will ease the pain: buy some graph paper. Once you get your circle started, it will be quite easy to forecast the majority of the remainder of coordinates for your ascii circle. This will help you ensure that all points are roughly at a 25 unit radius.

Clinton Portis 211 Practically a Posting Shark

Is formating your hard disk and re-installing an operating system an option for you?

Clinton Portis 211 Practically a Posting Shark

are there any guarantees that any id you come up with will unique.. if so, how will you make this determination...

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

Here I wrote a pretty good example of how to use an 'array of structs.' This data structure should be one of those go-to items in your bag of tricks as a CS student because so many times you will be tasked with creating some sort of database of information (bank accounts, hotel records, phone books, airline tickets.. the list goes on.)

Just as a hint, I would design your struct like this:

struct flights{

     string flight_name;
     int flight_number;   
};

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

flight flight_records[100];

Now all you have to do is populate your 'array of flights' by prompting for user input.

Get down with the 'array of structs' and use it frequently throughout your CS academic career.

Clinton Portis 211 Practically a Posting Shark

I would use C++ to create an 'array of structs'; each struct should contain attributes for class name and for class number. Then create an array of appropriate size of the aforementioned struct object. Populate the array by prompting for user input.

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

Here is a DOS console roulette game with ascii graphics.

Here is DOS console Blackjack game.

Here is a Blackjack windows app.

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

Try using the <ctime> library:
http://www.cplusplus.com/reference/clibrary/ctime/time/

code for a 3 second delay:

time_t start_time, cur_time;

         time(&start_time);
         do
         {
                 time(&cur_time);
         }
         while((cur_time - start_time) < 3);
Clinton Portis 211 Practically a Posting Shark

The use of a loop may not be warranted in this situation. It seems to me the code is procedurally linear; get user input, perform error checking, test user input, provide output with correct answer.

Using a loop, whether it be while, do/while, or for is usually implemented when several similar operations need to be performed.

One tip: when accepting input from the user, try using a <string> class object.. it will accept all kinds of jibberish and will not crash like trying to accept input strictly into an int, double, float etc.

Once your data has been accepted into the string, perform error checking on that string and then convert string to desired data type.

Clinton Portis 211 Practically a Posting Shark

Here is a good tutorial on using strtok(), it's written in C, but that's what you get for using c-strings teehee
http://cboard.cprogramming.com/cplusplus-programming/60924-cstring-algorithm-what-do-you-think.html

it offers this example:

/* strtok example */
#include <stdio.h>
#include <string.h>

int main ()
{
  char str[] ="- This, a sample string.";
  char * pch;
  printf ("Splitting string \"%s\" into tokens:\n",str);
  pch = strtok (str," ,.-");
  while (pch != NULL)
  {
    printf ("%s\n",pch);
    pch = strtok (NULL, " ,.-");
  }
  return 0;
}

Here is my first attempt at strtok()'ing:
http://cboard.cprogramming.com/cplusplus-programming/60924-cstring-algorithm-what-do-you-think.html

Clinton Portis 211 Practically a Posting Shark

Ok hombre, let's try this again...

just compile this code and tell me what displays on your DOS console:

#include <iostream>
using namespace std; 

int number_right (char let1, char let2, char let3, char let4, char let5, char let6);  

int main ()
{	

     int matches = 0;	

     char let1 = 0, let2 = 0, let3 = 0, 
          let4 = 0, let5 = 0, let6 = 0;      
     
     cout << "Enter 6 characters:  ";
     cin >> let1 >> let2 >> let3 >> let4 >> let5 >> let6;

     matches = number_right (let1, let2, let3, let4, let5, let6);
     
     cout << "\n\nThere are " << matches << " matches."; 

return 0;
} 

int number_right (char let1, char let2, char let3, char let4, char let5, char let6)	
{

     int set1 = 0, set2 = 0, set3 = 0; 

     if (let1 == let4) 
     {		
          cout << "The first letter is a match.\n"; 
          set1++; 
     }	
     else if (let2 == let5) 
     {		
          cout << "The second letter is a match.\n"; 
          set2++; 
     }		
     else if (let3 == let6) 
     {			
          cout << "The third letter is a match.\n"; 
          set3++; 
     }		
     else 		
     {			
          cout << "There is no match.\n"; 
     } 	

     return (set1 + set2 + set3);
}

Give me specific errors w/ line number (if any)

Clinton Portis 211 Practically a Posting Shark

Looks like ye' have done everything except the graphics... so I will offer ye' up a function for drawing an ascii circle.

This code is an algorithm called a, "Bresenham circle."

void DrawCircle(int x, int y, int radius)
  {
    int f = 1 - radius;
    int ddF_x = 1;
    int ddF_y = -2 * radius;
    int x = 0;
    int y = radius;
 
    outtextxy(x, y + radius);
    outtextxy(x, y - radius);
    outtextxy(x + radius, y);
    outtextxy(x - radius, y);
 
    while(x < y)
    {
      ddF_x == 2 * x + 1;
      ddF_y == -2 * y;
      f == x*x + y*y - radius*radius + 2*x - y + 1;
      if(f >= 0) 
      {
        y--;
        ddF_y += 2;
        f += ddF_y;
      }
      x++;
      ddF_x += 2;
      f += ddF_x;    
      outtextxy(x + x, y + y);
      outtextxy(x - x, y + y);
      outtextxy(x + x, y - y);
      outtextxy(x - x, y - y);
      outtextxy(x + y, y + x);
      outtextxy(x - y, y + x);
      outtextxy(x + y, y - x);
      outtextxy(x - y, y - x);
    }
  }

Of course, the other alternative would be to create a function where you individually outtextxy( ) every single point of the circle... but this would require a lot of trial and error.

Clinton Portis 211 Practically a Posting Shark

I don't have a compiler on me' laptop here.. but at first glance everything seems to look ok...

Q: how do you know it's not returning the proper value? I see no evidence of any output to determine the return value of number_right( ).

Clinton Portis 211 Practically a Posting Shark

You just completely misunderstood my question.

my bad. teehee.

Clinton Portis 211 Practically a Posting Shark

Here, you are attempting to assign a 'Nunu' object to another 'Nunu' object:

p[0] [B]=[/B] a;

//"Error 2 error C2582: 'operator =' function is unavailable"

Assignment among primitive data types, such as int, float, char, double, etc. is handled by the compiler with relative ease. But what happens when you try to assign data types of your own design?

Fortunately, there is a method available that will allow you the programmer to define how your aggregate data types will respond to various operations: Operator Overloading.

Here is a small example that illustrates how 'point' objects can be assigned to one another:

// assignment.cpp
class Point
{
public:
   Point &operator=( Point & );  // Right side is the argument.
   int _x, _y;
};

// Define assignment operator.
Point &Point::operator=( Point &ptRHS )
{
   _x = ptRHS._x;
   _y = ptRHS._y;

   return *this;  // Assignment operator returns left side.
}

In the above scenario, the x and y coordates are dereferrenced from the 'right side object' (the source object) and assigned to the x and y coordates to the 'left-hand side.' The compiler knows how to handle assignment between two 'points' objects.

point p1, p2, p3;

p1 [B]=[/B] p2;
p2 [B]=[/B] p3;
//overloaded assignment operators at work, handling their 'left-hand side' and 'right-hand side' arguments

Operator overloading give the programmer great flexibility to assign user-defined objects to other user-defined objects. The assignment operator (=) in my opinion is probably the easiest operator to overload. With a …

Clinton Portis 211 Practically a Posting Shark

Try this:

#include<iostream>
#include<sstream>
#include<string>
using namespace std;

int main()
{
     ostringstream oss;
     double number = 0.0;
     string string_number;

     cout << "Enter number:  ";
     cin >> number;

     oss << number;
     string_number = oss.str();

     cout << "\n\nThe number you entered is:  " << string_number;

return 0;
}

The above example is based on this tutorial: http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1045689663&id=1043284385

Clinton Portis 211 Practically a Posting Shark

:D

Clinton Portis 211 Practically a Posting Shark
if (StatsChange == "Strength" or "strength" or "str" or "STR" or "Str")

should be:

if (StatsChange == "Strength" || StatsChange == "strength" || StatsChange== "str" || StatsChange== "STR" ||StatsChange== "Str")

I know, believe me I did the same thing when I first got into boolean logic.. because the way you do it (aside from the incorrect symbology) seems correct at first, and more code efficient. However, please realize that there are specific rules at play here; each expression is handled individually.

If only one variable exists, the boolean test will either return TRUE if not zero, and FALSE if zero. Example:

if(variable)
{
     //code 
}

In this instance, if 'variable' contains any value, it will test TRUE and will enter/execute the contents of the if() structure. Conversely, if 'variable' contains a zero, the boolean expression will test FALSE and will simply skip over the entire if() structure.

So like me, you are probably wondering how to avoid these huge multiple lines of logic. Here is one way I can think of:

string input = {"Strength", "strength", "str", "STR", "Str"};
bool match = FALSE:
int i=0;

do{
     if(StatsChange == input[i])
     {
          match = TRUE;
     }
}while(match == FALSE || i < 5);

Placing boolean tests inside of a loop could potentially eliminate several lines of logical testing.

Clinton Portis 211 Practically a Posting Shark
#include<windows.h>
#include<iostream>
using namespace std;

int main()
{
     char hello[11] = {'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'};

     for(int i=0, i<11, i++)
     {
          cout.put(hello[i]);
          Sleep(500);
     }
return 0;
}
Clinton Portis 211 Practically a Posting Shark

The most popular method of delay is to use the Sleep() function, a member of the <windows.h> library.

Clinton Portis 211 Practically a Posting Shark

I'm not sure of the relevance of Python in today's modern IT world.. but my advice is to spend at some time and do a local job search for software engineers. In my experience, most companies want software engineers that are good in all areas: website design, databases, C, C++, Java, Javascript.. and usually 3 or 4 other things that I don't even understand. In my searching, I have never seen any company specifically asking for python.

Clinton Portis 211 Practically a Posting Shark
Clinton Portis 211 Practically a Posting Shark

More Considerations: Some hands will test TRUE in more than one function; example: a hand containing 2-pair will also test TRUE for 1-pair... a hand containing a straight-flush will also test TRUE for a straight and for a flush, so be prepared to handle these situations accordingly.

Clinton Portis 211 Practically a Posting Shark

Are you feeling lucky...

I'm gonna go all-in on this; I've written a few ascii table games so I know what ye' are talking aboot here.

There are of course many ways to do this. I would suggest to write specific functions to test every possible winning situation that can occur in the game of poker. Then you can pass players 'hands' into each function. The functions could be designed to return TRUE for each test.

Without getting hot and heavy into each function definition, I'll just give you a general overview of the suggested design:

struct card{
 
     string suite;
     int value;
};

//Function prototypes:
bool is_one_pair(card&);
bool is_two_pair(card&);
bool is_three_of_kind(card&);
bool is_straight(card&);
bool is_flush(card&);
bool is_full_house(card&);
bool is_four_of_kind(card&);
bool is_straight_flush(card&);
void high_card(card&);
  
//create containers that will represent a hand for each player
card player1_hand[5], player2_hand[5], player3_hand[5], player4_hand[5];


//Now the part ye' been askin' aboot

//Somewhere along the line you can do something like this:

if (is_one_pair(player1_hand))
{
     //code to handle hand containing 1 pair
}
else if(is_two_pair(player1_hand))
{
     //code to handle hand containing 2 pair
}
else if(is_three_of_kind(player1_hand))
{
     //code to handle hand containing 3 of a kind
}
else if(is_straight(player1_hand))
{
     //code to handle hand containing a straight
}
else if(is_flush(player1_hand))
{
     //code to handle hand containing a flush
}
else if(is_full_house(player1_hand))
{
     //code to handle hand containg a full house
}
else if(is_four_of_kind(player1_hand))
{
     //code to handle hand containing 4 of a kind
}
else if(is_straight_flush(player1_hand))
{
     //code to handle a straight flush …
Clinton Portis 211 Practically a Posting Shark

I would use c++ to prompt the user for 10 integers. Each entry could be stored in an array of integers.

At this point, you could display a menu of options on how the user would like to sort the array; which sorting method to use, and to sort either in acending or decending order.

You can then perform the various sorting algorithms on the array. After the desired sorting operation has taken place, you could probably display the newly sorted array contents.

Clinton Portis 211 Practically a Posting Shark

I would use c++ to design a menu type structure. You should display a menu using iostream objects, such as cout. After your menu is displayed, you should prompt the user for a menu choice.

One structure in mind that lends itself to handling menus is use of the switch( ).

Hope this helps.

Clinton Portis 211 Practically a Posting Shark

Now that you are using <string> class objects, it is time to unlock the magic of the almighty string.

Here is a list of string object members:
http://www.cplusplus.com/reference/string/string/

On of them that you may find of particular interest is the find( ) function, which will return the element position of a character, or the first position of a word.

int index = 0;
string sentence = "My IQ is < than schfifty-five";

index = sentence.find('<');

cout << "The element position of < is located at sentence[" << index << "]";

Another member ye' may find of interest is substr( ) which gives you the ability to extract a piece of a string:

string sentence = "More than a feeling.";
string sub;

sub = sentence.substr(6,4);

cout << "More " << sub << " a feeling.";

One more member of interest, since you are performing array operations on your strings, be sure not to run out of bounds of the array.. that's where size( ) comes in:

string sentence = "We should just be friends";

for(int i=0; i<sentence.size(); i++)
{
     //now you will never run out of bounds on your <string> class objects teehee
}
Clinton Portis 211 Practically a Posting Shark

You are forcing it to write...

for (counter=1;counter<=10;counter++)

A preferred method of reading a file:

while(infile >> lastname >> firstname)
{
     .... 
     .....
     ......  
      etc. etc. etc.
}