We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,725 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

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.

2
Contributors
3
Replies
10 Hours
Discussion Span
8 Years Ago
Last Updated
4
Views
souphmars
Newbie Poster
13 posts since Oct 2004
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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
Skill Endorsements: 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(...){}
}
souphmars
Newbie Poster
13 posts since Oct 2004
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

can anybody help me

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

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0908 seconds using 2.72MB