Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   Error reading cout function on line 19 (http://www.programmingforums.org/showthread.php?t=13690)

Z3nathur Aug 1st, 2007 11:58 PM

Error reading cout function on line 19
 
Ok so i fixed a few of the problems and now it runs almost as it should but since i was using a while loop i wasn't doing all too well lol. i put in a do while loop in the hopes that i would be able to run it through and have it break the loop when the third if statement(line 45) was chosen but for some reason i can't even get the compiler to output the cout statement on line 19. do i need to do something other than compile?

. Is there a more effective and less lag-inducing replacement for system("PAUSE")? i'm having trouble finding something at the moment although i figure that there must be some simple code that solves the problem through anoth means other than forcing the system to intervene.

:

#include <iostream>

using namespace std;

int main()
{
    float age = 0;
    float human_age;
    int state;
    int choice;
    char nothing;
    state = 1;
    do
    {
          cout << "Welcome to Z3nathur's first conversion tool" << endl;
          cout << "Choose one of the options listed below and press enter to continue" << endl;
          cout << "1) Dog years -> Human Years" << endl;
          cout << "2) Human years -> Dog years" << endl;
          cout << "3) Close the program" << endl;
         
          cin >> choice;
          system("cls");
         
        if (state == 1, choice == 1)
        {
                  cout << "How old is your dog in dog years?" << endl;
                  cin >> age;
                  human_age = age/7;
                  cout << "Your dog is " << age << " years old in dog years and " << human_age << " years old in human years" << endl;
                  system("PAUSE");
                  system("cls");
                 
        }
   
        if (state == 1, choice == 2)
        {
                  cout << "How old is your dog in human years?" << endl;
                  cin >> human_age;
                  age = human_age*7;
                  cout << "Your dog is " << age << " years old in dog years and " << human_age << " years old in human years" << endl;
                  system("PAUSE");
                  system("cls");
        }
       
        if (state == 1, choice == 3)
        {
                  state++;
        }
       
       
    }while( state == 1);
 
    cout << "Press any key to close the program";
    cin >> nothing;
    return 0;
}


Z3nathur Aug 2nd, 2007 12:10 AM

ok i tried just starting a new project and copy-pasting my code into another console cpp and it solved the cout problem. which is discouraging because it means that the problem wasn't me. I still am stuck on getting the program to close though

DaWei Aug 2nd, 2007 12:14 AM

You have a number of issues. For instance,
:

if (state == 1, choice == 1)
I'm a little reluctant to pursue these, because you are not paying attention to the previous responses and the advice you have been given.

I have told you how to (portably) pause the program at the end. I have counseled you about checking your input for success. Not checking the input is the sign of an uninformed noob, or a schlock. You have, however, been previously informed.

If you choose not to accept the help that is offered, then why should anyone respond? Just curious.

Infinite Recursion Aug 2nd, 2007 12:22 AM

|| && ?!?!

Z3nathur Aug 2nd, 2007 12:54 AM

ok i'm going to take a few days and just learn different operators etc because it's obvious that i'm diving in too deep to start off without looking at all the variables (dawei you should get that d-ent). It isn't that i didnt listen to your advice on the compound operator, i also read Dark's comparison note on one of my posts and i think i misunderstood what he meant. I'll be back once i have a working first program of my own doing or have a question about syntax


All times are GMT -5. The time now is 2:57 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC