1.11M Members

how to add data from an array to a stack

 
0
 

i have sorted data in an array and sent to a file...how do i put this sorted data in a stack.

 
0
 

First, are you familiar with a stack and its methods?

If you are the process is simple. Based on what you have said,

while(!eof(yourfile))
{
fin >> temp;
stack.push(temp);
}

At the moment I am making the assumption you are familier with stacks and can declare the variables I used. If you don't let me know.

 
0
 

this is my code i need to get this array i sorted in this program to a stack then a que-within in this same main program

#include "c:\\ArrayTC_f04.h"
#include "c:\\StackArrC.h"
#include "c:\\QArrC.h"

void main()
{

	try
	{
		
		ifstream fin;
		ofstream fout;
		
		int arrsize;
		cout << "\nEnter array size ";
		cin >> arrsize;
		ArrayC<double> A(arrsize);
		fin.open("c:\\bankin.txt");
		if(!fin)throw FileException();
		fout.open("c:\\bankout.txt");
		if(!fout)throw FileException();
		fin >> A;
		cout << "array is \n" << A;
		cout<< " Sorted array " << endl;
		A.selectionSort();
        cout<<A<<endl;
		fout<<A<<endl;
		fin.close();
		fout.close();
		
		cout << endl;

	}
	catch(...){}
}
 
0
 

can anybody help me

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article