vividexstance's Profile User Rating: *****

Reputation: 665 Enlightened
Group:
Expert
Active Posts:
2,300 (1.68 per day)
Joined:
31-December 10
Profile Views:
11,311
Last Active:
User is offline Yesterday, 08:48 AM
Currently:
Offline

Previous Fields

Country:
Who Cares
OS Preference:
Who Cares
Favorite Browser:
Who Cares
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
0
Expert In:
C/C++

Latest Visitors

Icon   vividexstance has not set their status

Posts I've Made

  1. In Topic: unknown problem, no error but program stop working after 1st call

    Posted 28 Sep 2014

    When I run your program, I get a logic exception thrown from the std::string class.

    This is the exception I'm getting:

    Quote

    terminate called after throwing an instance of 'std::logic_error'
    what(): basic_string::_S_construct null not valid


    This line is causing it (199):
    string pf = '\0';
    
    


    Change those single quotes to double quotes.
  2. In Topic: unknown problem, no error but program stop working after 1st call

    Posted 28 Sep 2014

    I didn't say it would fix it, just showed you there were problems.

    What exactly happens when you run the program? Just saying it doesn't work isn't that helpful.

    EDIT:
    Please post your updated code?
  3. In Topic: creating a water bill using c

    Posted 28 Sep 2014

    What happens when you try to compile it? Do you get warnings/errors? Does it compile fine? Does the program run? Does it display the expected results?

    This is not a homework writing service, you need to show some effort. And I'll give a hint, no the program is not correct, look carefully at your if-else statements and the number of parentheses.
  4. In Topic: unknown problem, no error but program stop working after 1st call

    Posted 28 Sep 2014

    You need to increase your compiler's warning/error level because when I compile your code with all warnings/errors enabled, I get this:

    Quote

    $ g++ -Wall stack.cpp -o stack
    stack.cpp: In member function ‘char stack::pop()’:
    stack.cpp:67:7: warning: unused variable ‘item’ [-Wunused-variable]
    char item;
    ^
    stack.cpp: In member function ‘bool stack::isOperator(char)’:
    stack.cpp:177:15: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
    if (num = '+')
    ^
    stack.cpp:179:20: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
    else if (num = '-')
    ^
    stack.cpp:181:20: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
    else if (num = '*')
    ^
    stack.cpp:183:20: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
    else if (num = '/')
    ^
    stack.cpp:185:20: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
    else if (num = '(')
    ^
    stack.cpp:187:20: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
    else if (num = ')')
    ^
    stack.cpp: In member function ‘char stack::pop()’:
    stack.cpp:77:1: warning: control reaches end of non-void function [-Wreturn-type]
    } //end pop
    ^
    stack.cpp: In member function ‘char stack::stackTop()’:
    stack.cpp:87:1: warning: control reaches end of non-void function [-Wreturn-type]
    } // end stackTop
    ^


    Remember that there is a difference between a single assignment operator and two. Just one means its an assignment, two means its a comparison.

    *EDIT*:
    Please don't make duplicate topics for the same program.
  5. In Topic: C++ Homework Help with Arrays - I've done work, need help refining

    Posted 27 Sep 2014

    Declaring all the variables at the top of the main() function is how you do it in C, whereas C++ allows you to declare them where you need them. I agree with the others that you should keep the variable declarations close to where the variable is actually used.

    One exception, in my opinion, is in loops. I typically would declare the variable just outside the loop and use it in the loop instead of declaring the variable inside the loop's body. This might not be a big deal with modern compilers that perform optimizations for you. But you can always write code that helps the compiler in performing these optimizations.

My Information

Member Title:
D.I.C Lover
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Comments

Page 1 of 1
  1. Photo

    orihotomihsah Icon

    09 Sep 2013 - 09:45
    Hi
Page 1 of 1