954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to add data from an array to a stack

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

souphmars
Newbie Poster
13 posts since Oct 2004
Reputation Points: 10
Solved Threads: 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.

jasweb2002
Junior Poster in Training
56 posts since Sep 2004
Reputation Points: 11
Solved Threads: 2
 

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(...){}
}
souphmars
Newbie Poster
13 posts since Oct 2004
Reputation Points: 10
Solved Threads: 0
 

can anybody help me

souphmars
Newbie Poster
13 posts since Oct 2004
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You