Thread: how do you make a program send data to the printer?

  1. #16
    n00b programmer
    Join Date
    Oct 2005
    Posts
    15
    It still doesn't work, I have no idea what's wrong. Ugg, I'm only on chapter 5 in my C++ book...
    Home is where the computer is
    I like the smell of the treats!
    Mmmm, Root Beer...

  2. #17
    ^ Read Backwards^
    Join Date
    Sep 2005
    Location
    Earth
    Posts
    282
    Code:
    #include <iostream>
    #include <fstream>
    #include <string>
    
    using namespace std; //If you are just doing a simple program and only going to be
    //using standard namespace, it is easier (and cleaner) to declare it globaly instead
    //of usting std:: infront of every freakin thing.
    
    
    
    string liftName; //Use string instead of char array
    int Max;
    
    int liftingPlanner (string liftName, int Max)
             {
                   cout << "Lift: " <<liftName<<"\n";
                   cout << "                Sets              \n";
                    cout << "Day ||  1    2    3    4    5\n";
                    cout << "| 1 || " <<Max*.6<< " "<<Max*.65<<" "<<Max*.7<<" "<<Max*.75<<" "<<Max*.7<<"\n";
                    cout << "| 2 || " <<Max*.65<< " "<<Max*.7<<" "<<Max*.75<<" "<<Max*.8<<" "<<Max*.75<<"\n";
                    cout << "| 3 || " <<Max*.7<< " "<<Max*.75<<" "<<Max*.8<<" "<<Max*.85<<" "<<Max*.8<<"\n";
                    cout << "| 4 || " <<Max*.75<< " "<<Max*.8<<" "<<Max*.85<<" "<<Max*.9<<" "<<Max*.85<<"\n"; 
                    cout << "| Max Day! || *Warm up before maxing* || Max Day!|\n";
                    return 0;
                    }
                    
    
    int main()
    {     
          system ("COLOR 1F ");
          int counter = 0;
          while(counter < 10)
          {    
          cout <<"This program was created by not telling you my real name ;) \nfor BHS in October of 2005\n";
          system ("PAUSE");
          
          cout <<"Enter the name of your first lift.\n";
          getline(cin,liftName); //getline alows you to get spaces too...so for example 'bench press' can be entered
    	  cout << "Enter your max:\n";
          cin >> Max;
          liftingPlanner (liftName, Max);
          counter++;
          
          return 0;
          }
          system ("PAUSE");
          return 0;
    }
    That 'fixes' what you posted last.
    I assume the return 0 in the file loop is just to stop the loop while you are working on it...

  3. #18
    n00b programmer
    Join Date
    Oct 2005
    Posts
    15
    I assume the return 0 in the file loop is just to stop the loop while you are working on it...
    Uh, ya, thats why it's there. Lol, no, I would have just left it there if you hadn't pointed it out to me! Or do I need it because main() isn't declared as void? I tried your edited version of the code. It compiled fine but when I ran the program it exited when it got to the point where it calls liftingPlanner. I hate to say it again but, any help would be appreciated.
    Home is where the computer is
    I like the smell of the treats!
    Mmmm, Root Beer...

  4. #19
    ^ Read Backwards^
    Join Date
    Sep 2005
    Location
    Earth
    Posts
    282
    It compiled fine but when I ran the program it exited when it got to the point where it calls liftingPlanner. I hate to say it again but, any help would be appreciated.

    Ohh. Well, it exited because the program was complete.
    Just put your system(“pause”); in front of your temporary ‘return 0’ in the while loop (just like you have at the end of the main function). Or delete that return 0 in the loop.

  5. #20
    n00b programmer
    Join Date
    Oct 2005
    Posts
    15
    I feel like I am being kind of needy, so I am going to finish my C++ book then debug my program. If I still need help, I will be back (of course...)
    Home is where the computer is
    I like the smell of the treats!
    Mmmm, Root Beer...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Where's the EPIPE signal?
    By marc.andrysco in forum Networking/Device Communication
    Replies: 0
    Last Post: 12-23-2006, 08:04 PM
  2. Program Crashing
    By Pressure in forum C Programming
    Replies: 3
    Last Post: 04-18-2005, 10:28 PM
  3. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  4. Need help fixing bugs in data parsing program
    By daluu in forum C Programming
    Replies: 8
    Last Post: 03-27-2003, 06:02 PM
  5. send data to printer and print on paper
    By ooosawaddee3 in forum C Programming
    Replies: 1
    Last Post: 07-22-2002, 05:19 AM