strings, char and sorting
hey everyone, i have a question. I am writing a program that sorts a list of lines of text. I read in each line of text into a string class string, manipulate that string, then once it is manipulated I need to save it to an array to sort later. Im trying to figure out how to take the string I have after it has been cleaned up, and put it into one element of an array. for example i want to do this string1 = array[0]. so that each individual element of the array[] would contain a whole line of text, so then i could sort (alphabetize) that array. can anyone help me.
ive tired tons of things but cant get the whole line of text from the string into a place where i can compare the different lines with each other to sort.
thanks
rjr
[758 byte] By [
rjr] at [2007-11-11 10:24:49]

# 1 Re: strings, char and sorting
thx
well at the end I just defined the functions member in the same head file !!
.................................vect.h.............................. ...................
#ifndef VECT_H
#define VECT_H
class vect {
int x;
int y;
int z;
public :
void init(int,int,int);
void homoth(int,int,int);
void affiche();
};
void vect::init(int a,int b,int c){
x=a; y=b ; z=c;
}
void vect::homoth(int dx,int dy,int dz){
x=x*dx; y=y*dy; z=z*dz;
}
void vect::affiche(){
cout<<"je suis dans le point" <<x<<":"<<y<<":"<<z<<endl;
}
#endif
.................................................................... ....................
so I used just the head file "vect.h" and the main one "vect2.cpp"..
and it works in spite of some warnin' message !! (any way I still don't know why the fisrt method won't work for me even if it's the classic one !!!)
# 2 Re: strings, char and sorting
Oups Soryy !!!
I was thinkin' it was another articl !! really sorry !! :SICK: :(
# 3 Re: strings, char and sorting
You should be able to store your strings in an array (or the more dynamic structure, vector) or even one of the sorted collections like map or multimap, where the elements are held in sorted order.
nspils at 2007-11-11 21:00:54 >
