Hello,
can anyone help me make a program in c++ where i can make a shop-like receipt with the total price and the date etc, and then print it off?
help would be greatly appreciated, thanks.
Hello,
can anyone help me make a program in c++ where i can make a shop-like receipt with the total price and the date etc, and then print it off?
help would be greatly appreciated, thanks.
once ive entered the price and date i dont know how to print it off from c++ in receipt form
I recommend doing a search of the board using print as the keyword.
Basically, there is no standard way to print with a printer in C++. I have seen a solution where the output stream is redirected to the printer rather than the screen. I have seen where "LPT1", or whatever port your printer is on, is used as a filename to associate with an fstream thereby using the printer as a file. I have also seen where the data is sent to a file, then a different program is called, and that program has a print function that can be ued to print the data. You may find other solutions by searching the board, too.
Try something like this, assuming you're using "print" in a generic form, as in "print to the screen":
Code:#include <vector> #include <cstdio> using namespace std; int main() { vector< float > prices; vector< string > names; // Code to fill in vectors should go here float sum = 0.0; vector< float >::const_iterator curPrice; vector< string >::const_iterator curName; for (curPrice = prices.begin(), curItem = desc.begin(); curPrice != prices.end() && curItem != desc.end(); curPrice++, curItem++ ) { printf("%-20s $%6.2f\n",(*curItem).c_str(),*curPrice); sum += *curPrice; } printf("%20s $%6.2f\n","Total:",sum); }
Claus Hetzer
Compiler: Borland 5.5 (on Windows)
Solaris CC (on Unix)
Known Languages: C++, MATLAB, Perl, Java