here is my code. in void function lookupInfo, how to i test the 2 strings for equality? everything works except the if statement.
#include <iostream.h>
#include <fstream.h>
#include <ctype.h>
#include <string.h>
struct inputInfo
{
char name[25];
short ext;
};
void enterInfo();
void lookupInfo();
void main()
{ char choice = ' ';
cout<< "Enter E to enter info or L to lookup info or Q to quit: ";
cin>> choice;
cin.ignore (100,'\n');
choice = toupper(choice);
while( choice != 'Q')
{
if (choice == 'E')
enterInfo();
else
if(choice == 'L')
lookupInfo();
cout<< "Enter E to enter info or L to lookup info or Q to quit: ";
cin>> choice;
cin.ignore (100,'\n');
choice = toupper(choice);
}
}
void enterInfo()
{
inputInfo record = {"",0};
ofstream outFile;
outFile.open ("T7Be08.dat",ios::app);
if (!outFile.fail () )
{
cout<< "Enter name: ";
cin.get (record.name,25,'\n');
cin.ignore (100,'\n');
cout<< "Enter extention number: ";
cin>> record.ext;
cin.ignore (100,'\n');
outFile<< record.name << '#'<< record.ext << endl;
outFile.close ();
}
else
cout<< "File not opened"<< endl;
}
void lookupInfo()
{
char lookupName[25]= "";
cout<< "Enter lookup name: ";
cin.get (lookupName,25,'\n');
cin.ignore (100,'\n');
inputInfo record = {"",0};
ifstream inFile;
inFile.open ("T7Be08.dat",ios::in);
if (!inFile.fail () )
{
inFile.get (record.name ,25,'#');
inFile.ignore (1);
inFile>> record.ext ;
inFile.ignore (1);
while (!inFile.eof () )
{
// if (stricmp(record.name,lookupName) == 0 ) how
// do i test these 2 strings for equality?
// {
cout<< record.name << '\n';
cout<< record.ext << '\n';
inFile.get (record.name ,25,'#');
inFile.ignore (1);
inFile>> record.ext ;
inFile.ignore (1) ;
// }
}
}
}