-
need some help
I am writing a program to take in data into a file, close the file. Then re open the file, ask for terminal number person wants to see, program needs to display all information entered for that terminal number.
Here is my problem , no matter what terminal number I enter the last information entered is what is displayed.
how do I make this work. Thanks in advance for your suggestions and help.
Code:
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include<cassert>
#include <math.h>
using namespace std;
void main()
{
string bldg;
char accessCode;
int transRate;
string termType;
int serviceDay;
int serviceMonth;
int serviceYear;
int TermNumber;
int TotalTerm;
ofstream outStream;
outStream.open("OutputFile.TXT");
cout << "Enter total number of Terminals to store " << "\n";
cin >> TotalTerm;
for (int i=0; i < TotalTerm; i++)
{
cout << "Enter Terminal Number: " << "\n";
cin >> TermNumber;
cout << "Enter Transmission rate: " << "\n";
cin >> transRate;
cout << "Enter terminal type: " << "\n";
cin >> termType;
cout << "Enter building terminal is located: " << "\n";
cin >> bldg;
cout << "Enter access code to terminal: " << "\n";
cin >> accessCode;
cout << "Enter day of last servicing date (dd): " << "\n";
cin >> serviceDay;
cout << "Enter month of last servicing date (mm): " << "\n";
cin >> serviceMonth;
cout << "Enter year of the last servicing date (YYYY): " << "\n";
cin >> serviceYear;
}
outStream.close();
/* This section gets value from the closed file */
ifstream inFile("OutputFile.TXT", ios::end);
if(!inFile)
{
cerr << "File could not be opened!" << "\n";
exit (1);
}
cout << "Enter Terminal number to search for: " << "\n";
int search;
cin >> search;
char ch;
ch = inFile.get();
if (search = TermNumber)
cout << TotalTerm << " " << bldg << " " << accessCode << "\n";
cout << transRate << " " << termType << " " << serviceDay << "\n";
cout << serviceMonth << " " << serviceYear << "\n";
}
-
That should be int main(). [edit] http://faq.cprogramming.com/cgi-bin/...&id=1043284376 [/edit]
Code:
if (search = TermNumber)
->
Code:
if (search == TermNumber)
and don't forget the curly braces {}.
exit() is in <cstdlib>. <math.h> is <cmath> in C++.
You don't actually write anything to the file; try
Code:
outStream << variable
-
thanks for the suggestions. I still have the same problem, if i you run the program and enter the data for 2 terminals. Only the last one entered comes up after i search for a terminal.
-
You do not keep track of the records entered. Every time you go through the loop, you get information into some variables, and in the next pass through the loop, they are overwritten with new data. You will want to write your data to a file after you have gathered it, in each pass of the loop. You might need to have a funny little tag for your data so that you can find it, or store the terminal data one per line. Later, you might just want to make an array or vector of TermData things which you could hold in a structure:
Code:
struct TermData
{
string bldg;
char accessCode;
int transRate;
string termType;
int serviceDay;
int serviceMonth;
int serviceYear;
int TermNumber;
};
Or have parallel arrays of this data, but that is worse design. If it is an assignment though, then whatever.
-
i dont think a struct would work for what i am attempting to do. I need the program to find the data within the file. I just built the struct still does the same thing shows only the last terminal entered.
-
I dont see how your code is searching for anything?
Seems like all it does is basicly nothing, cept for get user input, then display it at the end of code
and where are you getting the values from the file and adding them back into variables to be displayed? shouldnt you do something like
Code:
inFile >> variable >> variable >> variable >> variable >> variable; // and then display them
-
here is some revised code. the search function doesnt seem to find anything.
Code:
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include<cassert>
using namespace std;
void main()
{
string bldg;
char accessCode;
int transRate;
string termType;
int serviceDay;
int serviceMonth;
int serviceYear;
int TermNumber;
int TotalTerm;
ofstream outStream;
outStream.open("OutputFile.TXT");
cout << "Enter total number of Terminals to store (INT) " << "\n";
cin >> TotalTerm;
for (int i=0; i < TotalTerm; i++)
{
cout << "Enter Terminal Number (INT): " << "\n";
cin >> TermNumber;
cout << "Enter Transmission rate (INT): " << "\n";
cin >> transRate;
cout << "Enter terminal type (String): " << "\n";
cin >> termType;
cout << "Enter building terminal is located (String): " << "\n";
cin >> bldg;
cout << "Enter access code to terminal (Char): " << "\n";
cin >> accessCode;
cout << "Enter day of last servicing date (dd) (INT): " << "\n";
cin >> serviceDay;
cout << "Enter month of last servicing date (mm)(INT): " << "\n";
cin >> serviceMonth;
cout << "Enter year of the last servicing date (YYYY) (INT): " << "\n";
cin >> serviceYear;
}
outStream.close();
/* This section gets value from the closed file */
ifstream inFile("OutputFile.TXT", ios::end);
if(!inFile)
{
cerr << "File could not be opened!" << "\n";
exit (1);
}
inFile >> TermNumber >> transRate >> termType >> bldg >> accessCode >> serviceDay >> serviceMonth >> serviceYear;
cout << "Enter Terminal number to search for: " << "\n";
int search;
cin >> search;
char ch;
ch = inFile.get();
if (search == &TermNumber)
{
cout << TermNumber << " " << bldg << " " << accessCode << "\n";
cout << transRate << " " << termType << " " << serviceDay << "\n";
cout << serviceMonth << " " << serviceYear << "\n";
}
else
cout << "please re run the program" ;
}
-
umm, what code do you think searchs the file? and I see you added inFile >>; but you need to add the inFile after you have searched and went to the line or else the inFile will just put the last line into variable. also on your inFile why do you use ios::end?? I am sorry if I sound rude just having a bad day, but dont get em wrong I am just trying to help :)
EDIT: You could always use a little more space taking way and just make a .dat file for each thing, and then just have the file name be the ID number , and use c_str() to open the file. This way doesnt add very much space because a 1 line .dat file is only 4-50 bytes. So not like hardrive space is a problem, it would take hundreds to even make a megabyte, and I dont think 1 meg is really a big deal
-
Show me where you write to the file. You don't do it in the code you are showing us. You take the values from the user, and set the variables, then you never write those variables to the file.
EDIT:
Code:
cout << "Enter year of the last servicing date (YYYY) (INT): " << "\n";
Could be written as:
Code:
cout << "Enter year of the last servicing date (YYYY) (INT):\n";
All of the output in that section is like that.
-
how do i take the values and write them to the file???
infile >> varible >> varible etc..
-
It is the same as cout and cin, just with different names
Code:
ofstream out ( "afile.txt" );
out << variable << variable;
out.close();
ifstream in ( "afile.txt" );
if ( !in.is_open() ) {
cout << "File Failed to open" << endl;
}
else {
in >> variable >> variable;
}
-
Well, since you are using " outStream.open("OutputFile.TXT"); " You would write to it using outStream << variable; If you want to read how you plan on doing it, later in the file, then you will want to use outStream << variable << " ";
Here are some things you should read:
http://www.cprogramming.com/tutorial/lesson7.html
http://www.cprogramming.com/tutorial/lesson8.html
http://www.cprogramming.com/tutorial/lesson10.html
In general, go through the tutorials, they are there for a reason.
-
Nice point wraithen, although sierrava06 if you need any one on one help just PM me with a AIM address and I can help you in realtime instead of using forums. I think my AIM address is in my profile
-
Well i got up early this morning and thought maybe i can figure this stuff out. I am still at a stand still.
The command in the program for Ofstream is where my problem lies. The compile gets stuck on the OutFile part. Doesnt recognize it. Please look over my code and get me moving in a direction. These excercises in the book are killing me. The book doesnt have clear running programs utilizing the commands. Please assist
Code:
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include<cassert>
using namespace std;
void main()
{
string bldg;
char accessCode;
int transRate;
string termType;
int serviceDay;
int serviceMonth;
int serviceYear;
int TermNumber;
int TotalTerm;
cout << "Enter total number of Terminals to store (INT) " << "\n";
cin >> TotalTerm;
ofstream outfile;
for (int i=0; i < TotalTerm; i++)
{
cout << "Enter Terminal Number (INT): " << "\n";
cin >> TermNumber;
cout << "Enter Transmission rate (INT): " << "\n";
cin >> transRate;
cout << "Enter terminal type (String): " << "\n";
cin >> termType;
cout << "Enter building terminal is located (String): " << "\n";
cin >> bldg;
cout << "Enter access code to terminal (Char): " << "\n";
cin >> accessCode;
cout << "Enter day of last servicing date (dd) (INT): " << "\n";
cin >> serviceDay;
cout << "Enter month of last servicing date (mm)(INT): " << "\n";
cin >> serviceMonth;
cout << "Enter year of the last servicing date (YYYY) (INT): " << "\n";
cin >> serviceYear;
}
ofstream outFile("afile.txt");
outFile >> TermNumber >> transRate >> termType >> bldg >> accessCode >> serviceDay >> serviceMonth >> serviceYear;
outFile.close();
/* This section gets value from the closed file */
ifstream inFile("afile.txt");
if(!inFile)
{
cerr << "File could not be opened!" << "\n";
exit (1);
}
cout << "Enter Terminal number to search for: " << "\n";
int search;
cin >> search;
char ch;
inFile >> TermNumber >> transRate >> termType >> bldg >> accessCode >> serviceDay >> serviceMonth >> serviceYear;
if (search == TermNumber)
{
ch = inFile.get();
cout << TermNumber << " " << bldg << " " << accessCode << "\n";
cout << transRate << " " << termType << " " << serviceDay << "\n";
cout << serviceMonth << " " << serviceYear << "\n";
}
else
cout << "please re run the program" ;
}
-
Code:
outFile >> TermNumber >> transRate >> termType >> bldg >> accessCode >> serviceDay >> serviceMonth >> serviceYear;
you can't read from an output stream.
use
Code:
outFile << TermNumber << transRate << termType << bldg << accessCode << serviceDay << serviceMonth << serviceYear;
Kurt
-
you just got my feet moving. Thanks for the post. I was not seeing that.
Now I just need to figure out how to for example enter two sets of data through the loop above. Data is written to file. Then in the bottom search function be able to type termnumber 1 or 2 and get it to display the info.
Thanks again for getting me moving.
-
Okay thanks for that great info. I should of caught that , and my compliler should have said something about that. It did i just didnt understand what it was telling me.
here is the revised code. My search function doesnt work,,, it never finds a search == Termnumber and proceds to the error statement.
Any suggestions:
Code:
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include<cassert>
using namespace std;
void main()
{
string bldg;
char accessCode;
int transRate;
string termType;
int serviceDay;
int serviceMonth;
int serviceYear;
int TermNumber;
int TotalTerm;
cout << "Enter total number of Terminals to store (INT) " << "\n";
cin >> TotalTerm;
ofstream outFile("afile.txt");
assert(outFile.is_open());
for (int i=0; i < TotalTerm; i++)
{
cout << "Enter Terminal Number (INT): " << "\n";
cin >> TermNumber;
cout << "Enter Transmission rate (INT): " << "\n";
cin >> transRate;
cout << "Enter terminal type (String): " << "\n";
cin >> termType;
cout << "Enter building terminal is located (String): " << "\n";
cin >> bldg;
cout << "Enter access code to terminal (Char): " << "\n";
cin >> accessCode;
cout << "Enter day of last servicing date (dd) (INT): " << "\n";
cin >> serviceDay;
cout << "Enter month of last servicing date (mm)(INT): " << "\n";
cin >> serviceMonth;
cout << "Enter year of the last servicing date (YYYY) (INT): " << "\n";
cin >> serviceYear;
}
outFile << TermNumber << transRate << termType << bldg << accessCode << serviceDay << serviceMonth << serviceYear;
outFile.close();
/* This section gets value from the closed file */
ifstream inFile("afile.txt");
if(!inFile)
{
cerr << "File could not be opened!" << "\n";
exit (1);
}
cout << "Enter Terminal number to search for: " << "\n";
int search;
cin >> search;
char ch;
inFile >> TermNumber >> transRate >> termType >> bldg >> accessCode >> serviceDay >> serviceMonth >> serviceYear;
if (search == TermNumber)
{
ch = inFile.get();
cout << TermNumber << " " << bldg << " " << accessCode << "\n";
cout << transRate << " " << termType << " " << serviceDay << "\n";
cout << serviceMonth << " " << serviceYear << "\n";
}
else
cout << "please re run the program" ;
}
-
You are never writing more then one record to the file.
put the output statement inside the loop.
for the search part you have to use a loop as well.
Kurt
-
Thanks again for the suggestions. I put the output inside the loop and did some tests it appears the data gets written over with the next set of questions. Any suggestions on how to get it to keep both sets of data??
-
If that happenes then you propably open and close the output stream inside the loop as well.
show your code.
Kurt
-
Zuk I started to go down another route using a class still seems to have the same problems. Any suggestions??
Code:
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include<cassert>
using namespace std;
class TermInfo
{
public:
string bldg;
char accessCode;
int transRate;
string termType;
int serviceDay;
int serviceMonth;
int serviceYear;
int TermNumber;
};
void main()
{
/* int TotalTerm; */
int const TotalTerm = 2;
cout << "Enter two sets of data for your terminal entrys today" << "\n";
/* cin >> TotalTerm; */
ofstream outFile("afile.txt");
assert(outFile.is_open());
TermInfo info[TotalTerm];
for (int i=0; i < TotalTerm; i++)
{
cout << "Enter Terminal Number (INT): " << "\n";
cin >> info[i].TermNumber;
cout << "Enter Transmission rate (INT): " << "\n";
cin >> info[i].transRate;
cout << "Enter terminal type (String): " << "\n";
cin >> info[i].termType;
cout << "Enter building terminal is located (String): " << "\n";
cin >> info[i].bldg;
cout << "Enter access code to terminal (Char): " << "\n";
cin >> info[i].accessCode;
cout << "Enter day of last servicing date (dd) (INT): " << "\n";
cin >> info[i].serviceDay;
cout << "Enter month of last servicing date (mm)(INT): " << "\n";
cin >> info[i].serviceMonth;
cout << "Enter year of the last servicing date (YYYY) (INT): " << "\n";
cin >> info[i].serviceYear;
outFile << info[i].TermNumber << info[i].transRate << info[i].termType << info[i].bldg << info[i].accessCode << info[i].serviceDay << info[i].serviceMonth << info[i].serviceYear;
}
outFile.close();
/* This section gets value from the closed file */
ifstream inFile("afile.txt");
if(!inFile)
{
cerr << "File could not be opened!" << "\n";
exit (1);
}
cout << "Enter Terminal number to search for: " << "\n";
int search;
cin >> search;
char ch;
inFile >> info[i].TermNumber >> info[i].transRate >> info[i].termType >> info[i].bldg >> info[i].accessCode >> info[i].serviceDay >> info[i].serviceMonth >> info[i].serviceYear;
if (search == 1)
{
ch = inFile.get();
cout << info[i].TermNumber << " " << info[i].bldg << " " << info[i].accessCode << "\n";
cout << info[i].transRate << " " << info[i].termType << " " << info[i].serviceDay << "\n";
cout << info[i].serviceMonth << " " << info[i].serviceYear << "\n";
}
else
cout << "please re run the program" ;
}
-
as I said you have to put the reading into some loop as well
something like this
Code:
for ( int i = 0; i < TotalTerm; i++) {
char ch;
inFile >> info[i].TermNumber >> info[i].transRate >> info[i].termType >> info[i].bldg >> info[i].accessCode >> info[i].serviceDay >> info[i].serviceMonth >> info[i].serviceYear;
if (search == info[i].TermNumber ) {
cout << info[i].TermNumber << " " << info[i].bldg << " " << info[i].accessCode << "\n";
cout << info[i].transRate << " " << info[i].termType << " " << info[i].serviceDay << "\n";
cout << info[i].serviceMonth << " " << info[i].serviceYear << "\n";
}
}
BTW main returns int.
Kurt
-
This would be appropriate for you to output and input terminal records with overloaded << and >> stream operators. But anyways, you can put an endl at the end of each terminal record line:
Code:
outFile << info[i].TermNumber << info[i].transRate << info[i].termType << info[i].bldg << info[i].accessCode << info[i].serviceDay << info[i].serviceMonth << info[i].serviceYear << endl;
If you overload operator << to ouput your class, you can like
If you overload operator >> to input your class, you can like
Code:
while(infile >> yrclass)
{
if(search == yrclass.termnumbuh)
{
dostuf();
}
}
-
I agree it needs to be in a loop if you would want to output everything that was input above.
My problem is i need to prompt the user for which terminal they would like to see. I.E. 1 or 2. Then the data prints to the screen just for that terminal.
-
Well, if you did all that stream overloading like I said, then
Code:
while(infile >> yrclass)
{
if(search == yrclass.termnumbuh)
{
cout << yrclass;
}
}
Otherwise, just
Code:
while(infile >> yrclass.var1 >> yrclass.var2 >> yrclass.var3 /* and so on */)
{
if(search == yrclass.termnumbuh)
{
cout << yrclass.var1 << yrclass.var2 << yrclass.var3 /* and so on */;
}
}
-
Tonto
I am not following. I attempted to do what you are suggesting. Seems my compiler doesnt like the info part. I think i am missing the boat here. I am very new to this programming stuff.
-
This code compiles , but when i am prompted for which terminal i would like to see. I enter 1 and get press any key to continue.
here is the code:
Code:
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include<cassert>
using namespace std;
class TermInfo
{
public:
string bldg;
char accessCode;
int transRate;
string termType;
int serviceDay;
int serviceMonth;
int serviceYear;
int TermNumber;
};
void main()
{
/* int TotalTerm; */
int const TotalTerm = 2;
cout << "Enter two sets of data for your terminal entrys today" << "\n";
/* cin >> TotalTerm; */
ofstream outFile("afile.txt");
assert(outFile.is_open());
TermInfo info[TotalTerm];
for (int i=0; i < TotalTerm; i++)
{
cout << "Enter Terminal Number (INT): " << "\n";
cin >> info[i].TermNumber;
cout << "Enter Transmission rate (INT): " << "\n";
cin >> info[i].transRate;
cout << "Enter terminal type (String): " << "\n";
cin >> info[i].termType;
cout << "Enter building terminal is located (String): " << "\n";
cin >> info[i].bldg;
cout << "Enter access code to terminal (Char): " << "\n";
cin >> info[i].accessCode;
cout << "Enter day of last servicing date (dd) (INT): " << "\n";
cin >> info[i].serviceDay;
cout << "Enter month of last servicing date (mm)(INT): " << "\n";
cin >> info[i].serviceMonth;
cout << "Enter year of the last servicing date (YYYY) (INT): " << "\n";
cin >> info[i].serviceYear;
outFile << info[i].TermNumber << info[i].transRate << info[i].termType << info[i].bldg << info[i].accessCode << info[i].serviceDay << info[i].serviceMonth << info[i].serviceYear;
}
outFile.close();
/* This section gets value from the closed file */
ifstream inFile("afile.txt");
if(!inFile)
{
cerr << "File could not be opened!" << "\n";
exit (1);
}
cout << "Enter Terminal number to search for: " << "\n";
int search;
cin >> search;
char ch;
inFile >> info[i].TermNumber >> info[i].transRate >> info[i].termType >> info[i].bldg >> info[i].accessCode >> info[i].serviceDay >> info[i].serviceMonth >> info[i].serviceYear;
while(inFile >> info[i].TermNumber)
{
if(search == info[i].TermNumber)
{
cout << info[i].TermNumber << " " << info[i].bldg << " " << info[i].accessCode << "\n";
cout << info[i].transRate << " " << info[i].termType << " " << info[i].serviceDay << "\n";
cout << info[i].serviceMonth << " " << info[i].serviceYear << "\n";
}
else
cout << "please re run the program" ;
}
}
-
If you wanted to do it my special E-Z way, you would have to provide overloaded implementations of those operators to work on your classes. Um, read this. http://cpp.codenewbie.com/articles/c...g-Page_19.html But I provided the alternate way to do it without overloading them in my second example. Just for now, try not overloading those.
-
Okay, little find and replace action. It seems better to not use that info array any more, and especially not the variable i. Just have a new, temporary TermInfo.
Code:
cout << "Enter Terminal number to search for: " << "\n";
int search;
cin >> search;
TermInfo currentInfo;
while(inFile >> currentInfo.TermNumber >> currentInfo.transRate
>> currentInfo.termType >> currentInfo.bldg >> currentInfo.accessCode
>> currentInfo.serviceDay >> currentInfo.serviceMonth
>> currentInfo.serviceYear)
{
if(search == currentInfo.TermNumber)
{
cout << currentInfo.TermNumber << " " << currentInfo.bldg << " " << currentInfo.accessCode << "\n";
cout << currentInfo.transRate << " " << currentInfo.termType << " " << currentInfo.serviceDay << "\n";
cout << currentInfo.serviceMonth << " " << currentInfo.serviceYear << "\n";
}
else
cout << "please re run the program" ;
}
-
didnt the way i do it in the code posted just before your post , do it the non overloading way. I am very confused. attempting to read the link you provided now.
-
It was suggested before that you should write a delimiter (space) in the file. Otherwise all the numbers will be right after each other.
out << num1 << " " << num2 << " " << ...
-
i will make that adjustment now. any suggestions on how to get my search at the bottom to only print out the one of the inputs of the terminal information?
-
latest code still no data prints out get press any key to continue after i enter the number 1 to see the first input. I am so fraustrated with this program. Doing a programming class with no instructor near by is terrible.
I am having these problems with the excercises. man i cant wait for the test. lol I am getting it very slowly so maybe i will be okay.
Code:
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include<cassert>
using namespace std;
class TermInfo
{
public:
string bldg;
char accessCode;
int transRate;
string termType;
int serviceDay;
int serviceMonth;
int serviceYear;
int TermNumber;
};
void main()
{
/* int TotalTerm; */
int const TotalTerm = 2;
cout << "Enter two sets of data for your terminal entrys today" << "\n";
/* cin >> TotalTerm; */
ofstream outFile("afile.txt");
assert(outFile.is_open());
TermInfo info[TotalTerm];
for (int i=0; i < TotalTerm; i++)
{
cout << "Enter Terminal Number (INT): " << "\n";
cin >> info[i].TermNumber;
cout << "Enter Transmission rate (INT): " << "\n";
cin >> info[i].transRate;
cout << "Enter terminal type (String): " << "\n";
cin >> info[i].termType;
cout << "Enter building terminal is located (String): " << "\n";
cin >> info[i].bldg;
cout << "Enter access code to terminal (Char): " << "\n";
cin >> info[i].accessCode;
cout << "Enter day of last servicing date (dd) (INT): " << "\n";
cin >> info[i].serviceDay;
cout << "Enter month of last servicing date (mm)(INT): " << "\n";
cin >> info[i].serviceMonth;
cout << "Enter year of the last servicing date (YYYY) (INT): " << "\n";
cin >> info[i].serviceYear;
outFile << info[i].TermNumber << info[i].transRate << info[i].termType << info[i].bldg << info[i].accessCode << info[i].serviceDay << info[i].serviceMonth << info[i].serviceYear;
}
outFile.close();
/* This section gets value from the closed file */
ifstream inFile("afile.txt");
if(!inFile)
{
cerr << "File could not be opened!" << "\n";
exit (1);
}
cout << "Enter Terminal number to search for: " << "\n";
int search;
cin >> search;
TermInfo currentInfo;
while(inFile >> currentInfo.TermNumber >> currentInfo.transRate
>> currentInfo.termType >> currentInfo.bldg >> currentInfo.accessCode
>> currentInfo.serviceDay >> currentInfo.serviceMonth
>> currentInfo.serviceYear)
{
if(search == currentInfo.TermNumber)
{
cout << currentInfo.TermNumber << " " << currentInfo.bldg << " " << currentInfo.accessCode << "\n";
cout << currentInfo.transRate << " " << currentInfo.termType << " " << currentInfo.serviceDay << "\n";
cout << currentInfo.serviceMonth << " " << currentInfo.serviceYear << "\n";
}
else
cout << "please re run the program" ;
}
}
-
you are getting close.
like anon already said, you have to output some delimiter when writing the record.
Code:
outFile << info[i].TermNumber << " " << info[i].transRate << " " << info[i].termType << " " << info[i].bldg << " "<< info[i].accessCode << " "
<< info[i].serviceDay << " " << info[i].serviceMonth << " " << info[i].serviceYear << endl;
as long as you don't input any whitspace when reading the strings it should work.
if you want to allow whitespace in the strings you will have to write some different delimiter and use getline() to read the data.
Kurt
-
Thanks for all your help. I got it to work now. It seems the small things tend to cause more trouble than the ones you think are harder.
I appreciate the help guys
-
As already mentioned, this should be int main() . . . .