need help to make a program

This is a discussion on need help to make a program within the C++ Programming forums, part of the General Programming Boards category; Hello, can anyone help me make a program in c++ where i can make a shop-like receipt with the total ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    20

    need help to make a program

    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.

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    20
    once ive entered the price and date i dont know how to print it off from c++ in receipt form

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    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.

  4. #4
    Registered User
    Join Date
    Jun 2002
    Posts
    82
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with this program I'm trying to make
    By Sshakey6791 in forum C++ Programming
    Replies: 14
    Last Post: 12-01-2008, 04:03 PM
  2. Replies: 9
    Last Post: 06-17-2008, 12:38 PM
  3. want to make this small program...
    By psycho88 in forum C++ Programming
    Replies: 8
    Last Post: 11-30-2005, 02:05 AM
  4. How To Make The Program Installed In Program Files Folder?
    By javacvb in forum Windows Programming
    Replies: 4
    Last Post: 11-05-2003, 05:33 PM
  5. any suggestions on how to make this program smaller?
    By bajan_elf in forum C++ Programming
    Replies: 4
    Last Post: 05-12-2003, 04:24 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21