Hello, I will ask this in advance so that I will save more time. So,I'm building a program that will ask the user to enter a product ID and the program will output it's name and price. The question is should I perform the linear search(?)
in the ifstreamsource file or should I do it in another source file?
I will keep this thread updated. Thanks in advance.
#include <iostream>
#include <fstream>
usingnamespace std;
int Search(int Searcharray[], int sizeofArray, int searchValue);
int main ()
{
int i=0;
int productID;
char productName[100];
double Price[20];
ifstream infile("Productfile.txt");
if (infile.is_open())
{
while (!infile.eof())
{
infile >> productName[i] >> Price[i];
i++;//im stuck here
}
}
else
{
cout << "File not open" << endl;
}
}
int Search(int Searcharray[], int sizeofArray, int searchValue);
{
for (int i=0; i < sizeofArray; i++)
{
if (searchValue == Searcharray[i])
{
return i;
}
}
return -1;
}