hi all
I have written a block of code that answers the following:
Write a C function that reads from the user (keyboard) the information about the transistors in stock, and stores this information in the Stock structure.
input info was: different transistor, manufacturer’s ID, polarity, maximum power, current gain, number in stock
Now I have to print all the input data in tabular form. How do I do that? If I use printf(%s%s...) and then list the input data in the printf statement, it will only print the headings wont it? How do I print all the input data with correct data under each correct heading?
struct STOCK // Make a struct
{
int info1; // This is data in the struct.
int info2;
};
std::ifstream& operator >> (std::ifstream& in, STOCK& s)
{
return (in >> s.info1 >> s.info2); // cin>>MyStock will now read into info1 and info2
}
std::ofstream& operator << (std::ofstream& out, STOCK& s)
{
return (out << s.info1 << ' ' << s.info2); // cout<<MyStock will now print "info1 info2".
}