Alphabetical order using ASCII values

using ASCII to alphabetize a list of names

Page 1 of 1

1 Replies - 9050 Views - Last Post: 29 February 2008 - 01:11 AM Rate Topic: -----

#1 deaner2425  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 28-February 08

Alphabetical order using ASCII values

Post icon  Posted 28 February 2008 - 08:55 PM

i am working with data files in C++ and my problem is i have to read in a list a names form two different data files then output them into a third data file in alphabetical order. I have to alphabetize them by assigning them ascII values.

I am having trouble assigning ascii to the first letter of the string variable. im not sure how to do this. i declared my variables then tried to assign the ascii values but its not working

heres what i have
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
//declare variables
string name_1, name_2;
int i ;
char a ;

//declare input data files
ifstream data_1;
ifstream data_2;
//declare output data files
ifstream output;

//open data files"P:\\C++\\data_1.dat");"P:\\C++\\data_2.dat");

//if fails
if( ||
cout<<"Error with File"<<endl;
return 0;

while(!data_1.eof() && !data_2.eof())
char name_1;



Is This A Good Question/Topic? 0
  • +

Replies To: Alphabetical order using ASCII values

#2 no2pencil  Icon User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6627
  • View blog
  • Posts: 30,868
  • Joined: 10-May 07

Re: Alphabetical order using ASCII values

Posted 29 February 2008 - 01:11 AM

Welcome to Dream In Code
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1