CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

Search:

Type: Posts; User: jsg

Page 1 of 2 1 2

Search: Search took 0.02 seconds.

  1. Re: Help understanding the use of "return" in functions.

    main returns an int not a void.

    You should do something like:


    int main(int argc, char** argv) {
    // Your code here
    return EXIT_SUCCESS;
    }
  2. Replies
    6
    Views
    634

    Re: open file using "system(...);"

    That's a really sweet answer.
  3. Replies
    13
    Views
    1,313

    Re: Can someone help with my C++ problem?

    Egads man, you're killing me!


    #include <iostream>
    #include <cmath>
    #include <fstream>
    #include <cstdlib>
    #include <string>
    // This is a dichotomous key written in C++ since I didn't want...
  4. Replies
    13
    Views
    1,313

    Re: Can someone help with my C++ problem?

    Forget what I said, that crazy indentation made it too difficult to follow the logic. Make sure all your ifs are actually testing the right conditions, and although I still see the indentation as...
  5. Replies
    13
    Views
    1,313

    Re: Can someone help with my C++ problem?

    Your indentation is messed up, but what you need to do is make sure you are using || (logical or) and && (logical and) where appropriate.
  6. Thread: Whitespace for cin

    by jsg
    Replies
    5
    Views
    587

    Re: Whitespace for cin

    You should probably change those char[]s to strings:


    int what, size;
    string name, piece, research, where, amount, other;

    And where you have:

    Use:
  7. Replies
    6
    Views
    3,518

    Re: Change Maker Project...

    While I don't disagree with you, the OP presented his problem with the quarter being the most significant coin.

    It sounds an awful lot like a homework question, and I bet the problem doesn't...
  8. Re: Visual c++ : how to create dinamic number of edit boxes

    This sounds similar to what my friend needed to create a dynamic menu that can change during run-time.

    He used what he called pure virtual functions.

    Unfortunately, I'm still just learning, so...
  9. Replies
    3
    Views
    534

    Re: Value of x is unexpected

    Thank-you for the explanation, and now I see why it fails to produce the expected results. Changing the values to whole numbers fixes the problem and now it works fine.


    a = ta*100;
    q = gc(a,...
  10. Replies
    3
    Views
    534

    Value of x is unexpected

    A couple of days ago someone posted a question about a change-maker program. Coding a solution to the problem seemed like a fun little exercise to try.

    Here is the code:


    using namespace std;...
  11. Replies
    6
    Views
    3,518

    Re: Change Maker Project...

    How many quarters total?
    1.37 / 0.25 = 5.48
    5.48 throw away the remainder = 5
    Subtract total quarter value
    1.37 - (0.25 * 5) = 0.12
    This leaves 12 cents

    How many dimes?
    0.12 / 0.1 = 1.2...
  12. Replies
    7
    Views
    806

    Re: C++ style assignment not working

    I made a little program to try to understand


    int main() {
    int a = 10;
    a(20); // produces same error
    }


    So I guess the big clue was the word initialization. Once a variable...
  13. Replies
    7
    Views
    806

    Re: C++ style assignment not working

    I apologize, I'm still trying to learn the correct terms for things. I still don't understand why it works in some places, but not others. My book doesn't seem to explain why, it just says it can be...
  14. Replies
    21
    Views
    4,178

    Re: [RESOLVED] Segfault When Using strtok()

    I understand now. I've never looked at std:string's constructor, still trying to understand OOP ;)

    Your explanation about std::string's constructor answered that question, even though I wasn't...
  15. Replies
    7
    Views
    806

    C++ style assignment not working

    I read that C++ has a new type of assignment syntax that I can choose to utilize.
    I.e.


    int a(10); // C++ style
    int a = 10; // C stlye


    Sometimes this syntax fails, such as below:
  16. Replies
    21
    Views
    4,178

    Re: [RESOLVED] Segfault When Using strtok()

    This tip alone cut my execution times in half, thanks a ton.
  17. Replies
    21
    Views
    4,178

    Re: [RESOLVED] Segfault When Using strtok()

    I understand what you mean by passing by value and reference. Now when you say most objects, does that include things (don't know exactly the correct term to apply) such as shorts and doubles, etc? ...
  18. Replies
    5
    Views
    718

    Re: Confused about constructor initializations.

    Yes, I meant to do x = 0; in the second example.

    That article helped somewhat, I don't understand everything, but I do get the gist that initialization list are better to use than assignment in...
  19. Replies
    21
    Views
    4,178

    Re: [RESOLVED] Segfault When Using strtok()

    That looks like just what I need, thank you.
  20. Replies
    5
    Views
    718

    Confused about constructor initializations.

    I encountered the following while reading some C++ code.
    Consider these two code examples:



    class Foo { // Declares class Foo
    public:
    int x; // Member variable

    ...
  21. Replies
    21
    Views
    4,178

    Re: [RESOLVED] Segfault When Using strtok()

    I've recoded everything quite a bit, and I've tried to eliminate the use of char* or char[] (except when OpenGL returns one).

    Another thing I found is that OpenGL version strings are always in the...
  22. Replies
    21
    Views
    4,178

    Re: [RESOLVED] Segfault When Using strtok()

    I appreciate these tips. I can follow along with everything up to where you mentioned vectors. They still scare me. I will incorporate each of your suggestions above in turn. May as well try all...
  23. Replies
    21
    Views
    4,178

    Re: [RESOLVED] Segfault When Using strtok()

    Okay, I played around with it and now I see what you mean, thanks for dispelling my illusion. Learning as I go along..

    This is what I came up with to fix it:


    char szVersion[6] = "\0";...
  24. Replies
    21
    Views
    4,178

    Re: [RESOLVED] Segfault When Using strtok()

    But isn't that just the sort of thing using sizeof() is supposed to avoid?
    It should make it whatever size the thing happens to be, that's how I've come to understand it.

    I tried what you said...
  25. Replies
    21
    Views
    4,178

    Re: [RESOLVED] Segfault When Using strtok()

    Even though no one answered I still felt people were listening.

    Although it was a dumb mistake, I'm still proud of it in a way.
Results 1 to 25 of 29
Page 1 of 2 1 2





Click Here to Expand Forum to Full Width

Featured