well if i understood your suggestion and when i change code in mine if it worked id be happy but i am simply a newber with a book learning and that is way beyond me at the second but i have got my code to semi-work by using the atoi to convert the string to an integer for me but i still cant get it to do its job properly.
Code:
#include<iostream>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;
int main(){
int i=0, ii = 0, maxMovies;
int vvv[maxMovies];
string input;
char string[50]="place holder";
//command to prompt user for amount of movies
cout<< "How many movies do you want to add? ";
getline(cin,input);
//end command to prompt user for amount of movies
//set up loop situation to take the input from user and transfer it to X
stringstream(input)>> maxMovies;
//sets up array of however many X is with a limit of 50 characters
char movies[maxMovies][50];
char ratings[maxMovies][50];
int count[maxMovies];
system("cls");
while( i < maxMovies ){
cout <<"Enter Movie # "<<i+1<<" : ";
cin.getline(movies[i], 50);
cout <<"Enter Rating: ";
cin.getline(ratings[ii], 50);
system("cls");
i++;
ii++;
}
//converting rating in integer from string
int lo = 0;
int zztop = 0;
int zzjr = 0;
do
{
vvv[zztop] = atoi (ratings[zzjr]);
zztop++;
zzjr++;
lo++;
}
while ( lo <= maxMovies );
//end conversion of integer from string
int yu = 0;
int zz = 0;
int ily = 0;
int zzd = 0;
while (vvv[zzd] < vvv[zzd + 1] )
{
//strcpy (yu, vvv[zz]);
yu = vvv[zz];
vvv[zz] = vvv[zz+1];
vvv[zz + 1] = yu;
//strcpy (vvv[zz], vvv[zz+1]);
//strcpy (vvv[zz + 1], yu);
zz++;
ily++;
zzd++;
}
//test string copies from ratings[z] to ratings[z+1]
//int z = 0;
//strcpy (ratings[z + 1], ratings[z]);
system("pause");
system("cls");
cout << "Results Are As Follows :" << endl << endl;
i = -1 ;
ii = -1;
for ( int z = 0; z <= maxMovies - 1;)
{
i++;
ii++;
cout << movies[i]
<< endl
<< "Rating : "
<< vvv[z]
<< endl
<< endl;
z++;
}
cin.get();
return 0;
}
because now i am using
Code:
while (vvv[zzd] < vvv[zzd + 1] )
{
//strcpy (yu, vvv[zz]);
yu = vvv[zz];
vvv[zz] = vvv[zz+1];
vvv[zz + 1] = yu;
//strcpy (vvv[zz], vvv[zz+1]);
//strcpy (vvv[zz + 1], yu);
zz++;
ily++;
zzd++;
}
and still it only swaps the first 2 variables if needed but disregards the rest, and sorry but i dont understand your post it looks swell and im sure it works better but i cant understand it to the fullest so it doesnt help me as much sadly.