How do I get users input from edit1 box and search (iventory.txt) file and display the results in edit2.box?
Example:
user inputs in edit1 box Headphones
Search Results in edit2 box Headphones
What code do I need to put in OnSearch() to do this?
I know how to read all the data from the .txt file and I can display all the data in a MessageBox back to the user.
I'm stuck
Code:
void CMyiventoryDlg::OnSearch()
{
// TODO: Add your control notification handler code here
FILE*iventory; // File pointer
char buffer[365]; //setup buffer to store data
int i, ch;
// Open for read (will fail if file "data" does not exist)
if( (serials = fopen( "iventory.dat", "r" )) == NULL )
MessageBox("The file serials.txt was not opened"
else
MessageBox("The file 'iventory.dat' was opened" //testing
// Read in first 365 characters and place them into the buffer
ch = fgetc( serials );
for(i = 0; (i < 365) && (feof( serials ) == 0); i++)
{
buffer = (char)ch;
ch = fgetc( serials );
}
// add null to end of string
buffer = '\0';
MessageBox(buffer); // displays all data in MessageBox
fclose(iventory); //Close files
Example:
user inputs in edit1 box Headphones
Search Results in edit2 box Headphones
What code do I need to put in OnSearch() to do this?
I know how to read all the data from the .txt file and I can display all the data in a MessageBox back to the user.
I'm stuck
Code:
void CMyiventoryDlg::OnSearch()
{
// TODO: Add your control notification handler code here
FILE*iventory; // File pointer
char buffer[365]; //setup buffer to store data
int i, ch;
// Open for read (will fail if file "data" does not exist)
if( (serials = fopen( "iventory.dat", "r" )) == NULL )
MessageBox("The file serials.txt was not opened"
else
MessageBox("The file 'iventory.dat' was opened" //testing
// Read in first 365 characters and place them into the buffer
ch = fgetc( serials );
for(i = 0; (i < 365) && (feof( serials ) == 0); i++)
{
buffer = (char)ch;
ch = fgetc( serials );
}
// add null to end of string
buffer = '\0';
MessageBox(buffer); // displays all data in MessageBox
fclose(iventory); //Close files