Hi guys:

I created this code to read two file get their input and post certain output. My problem is that C++ is sorting out my output from smaller to greater. Is there a way that I can get c++ not to sort out the output.

Thanks:

Gus

Here is my code

#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

int main()
{
	char cmpFile[20];
	int numberRaw=10;
	int numberImages = 100;

	ifstream in,in2;
	in.open("stars.comp");
	in2.open("go.comp");
	ofstream out("basura.comp");

	
	double ierr,serr,verr,isn,iln,vn,x,y,sharp;
	vector<double> rawStar(numberImages);
	vector<double> idil(numberImages);
	vector<double> idis(numberImages);
	vector<double> idv(numberImages);
	vector<double> idile(numberImages);
	vector<double> idise(numberImages);
	vector<double> idve(numberImages);
	vector<double> stardId(numberRaw);
	for(int j=0;j<numberImages;j++)
	{
		in >>idil[j]>>idile[j]>>idv[j]>>idve[j]>>rawStar[j]>>sharp;
		for (int i=0; i<numberRaw; i++) 
			{
				in2 >>stardId[i];
				if (stardId[i]==rawStar[j])
				{
					out <<"  "<<idil[j]<<"   "<<idile[j]<<"  "<<idv[j]<<"   "<<idve[j]<<" "<<rawStar[j]<<" must be equal to "<<stardId[i]<<endl;
//					cout << rawStar[j] << " " << stardId[i];
				}
			}
		
	}
	out << endl;
	return 0;
}

There's no sorting going on in your code. Any ordering is coming from the files themselves.

Thanks your reply made me realize the problem. There are two files being read, one sorted out and unsorted. I need the input to be in the unsorted way, so instead of having

for(int j=0;j<numberImages;j++)
	{
		in >>idil[j]>>idile[j]>>idv[j]>>idve[j]>>rawStar[j]>>sharp;
		for (int i=0; i<numberRaw; i++) 
			{
				in2 >>stardId[i];

I need to write it

for (int i=0; i<numberRaw; i++) 
	{
		in2 >>stardId[i];
		for(int j=0;j<numberImages;j++)
			{
				in >>idil[j]>>idile[j]>>idv[j]>>idve[j]>>rawStar[j]>>sharp;

simple yet I overlooked that. Thanks

Gus

Since your problem is now resolved. Please mark your post as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.