Hi guys:

I am constructing this simply code to read a number of columns in a file, get a number and produce a new file. I am just not certain what is wrong. I used the same standard as an old code of mine so it should work but I get nothing. Any help.

Thanks,

Gus

//    C++ PROGRAM TO CREATE FILE XXX.CL 
//    Gustavo Cardona, 06JUN09
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

int main()
{
	char fileToRead[20];
	char fileToWrite[20];
	char programToRead[20];
	char corFile[20], filter[4], season[3];
	int numberImages;
	cout << "Enter name of input file to create command file: (e.g. comp_lpv.dat) ";
	cin >> fileToRead;
	cout << "Enter name for output file (e.g. comp_lpv.cl ";
	cin >> fileToWrite;
	cout << "How many companion stars: ";
	cin >> numberImages;
	cout << "Enter name of cor file (e.g. daom_il3.cor2) ";
	cin >> corFile;
	cout << "Enter the filter and season (e.g. il 3) ";
	cin >> filter, season;
	cout << "Name of the var file that you want to use: (e.g. var_instmag40.e) ";
	cin >> programToRead;
	ifstream in;
	in.open(fileToRead);
	ofstream out(fileToWrite);
	double xc, yc, ilmag, ilmage, ismag, ismage, vmag, vmage, vmi;
	vector<double> starId[numberImages];
	for(int i=0;i<numberImages;i++)
	{
		if (in >>xc>>yc>>starId[i]>>ilmag>>ilmage>>ismag>>ismage>>vmag>>vmage>>vmi) 
		{
			out << "!../vars/" << programToRead << " << DONE" << endl;
			out << corFile << endl;
			out << starId[i] << endl;
			out << "daom_" << filter << season << ".varinst." << starId[i] << endl;
		}
		out << "DONE" << endl;
	}
	return 0;
}

Recommended Answers

All 2 Replies

Try changing cin >> filter, season; to cin >> filter >> season;

Thanks, I feel dumb I did not notice that. It runs smoothly right now

Gus

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.