Search:

Type: Posts; User: edoceo

Page 1 of 2 1 2

Search: Search took 0.00 seconds.

  1. Replies
    11
    Views
    1,601

    I tried explaining what was going on with the...

    I tried explaining what was going on with the "extra set of parens". A int(*)[5] incremented by one, dereference this new pointer to look at the first element of this imaginary array, then move back...
  2. Replies
    11
    Views
    1,601

    #include int main (int argc, char...

    #include <iostream>

    int
    main (int argc, char * argv[])
    {
    int x[] = {1,2,3,4,5};

    std::cout << *((*(&x+1))-1) << std::endl;
    }
  3. Replies
    5
    Views
    859

    void func1 (int &a) { func2 (a); } void...

    void func1 (int &a) {
    func2 (a);
    }

    void func2 (int &a) {
    a = 3;
    }


    pass the arguments to 'playerMove' as references aswell if you want to be able to change their values.
  4. Replies
    5
    Views
    1,437

    class A { public: A (int x) {}; }; ...

    class A {
    public:
    A (int x) {};
    };

    class B {
    public:
    B (int x) : m_A (x) {}

    private:
  5. Replies
    3
    Views
    2,718

    I'm guessing you having been copy+pasting a bit...

    I'm guessing you having been copy+pasting a bit wrong since the if-statements on line #14, #16 and #18 are still "wrong"*

    You should also go through the logic of your program to find some other...
  6. Replies
    3
    Views
    2,718

    for starters, use else if instead of just using...

    for starters, use else if instead of just using if (icecream == ""), if (sauce == "") and if (sprinkles == "").

    edit
    When I look closer to your source I see that there are more places where you...
  7. Replies
    3
    Views
    1,364

    > I need that on every character entered it...

    > I need that on every character entered it checks whether it's numeral or not....if not then do not accept..

    if you want the input to be stored inside a std::string, read my post above.
    ...
  8. Replies
    3
    Views
    1,364

    read the input as you normally would (into a...

    read the input as you normally would (into a std::string-instance), then use std::string::find_first_not_of, passing a string with all valid characters . If the function doesn't returns...
  9. Thread: rand()

    by edoceo
    Replies
    3
    Views
    1,124

    >Will increasing xincrease (ie, 'b') increase the...

    >Will increasing xincrease (ie, 'b') increase the probability of the statement being true?

    No, decreasing it will increase the probability of the statement being true.

    rand() % 1 == 0, true for...
  10. Thread: this pointer?

    by edoceo
    Replies
    38
    Views
    2,635

    I'm a slowpoke but: the *this-pointer inside a...

    I'm a slowpoke but:

    the *this-pointer inside a class is good for many things, for example if you got a class-function where you have a parameter with the same name as a class-member, when you want...
  11. Replies
    8
    Views
    961

    Why don't you write a simple program to check...

    Why don't you write a simple program to check just that?



    if ((&(A[5]))-3) == (A+2)) {
    printf ("same addr!\n");
    } else {
    printf ("doh!\n");
    }
  12. Replies
    7
    Views
    1,128

    yes, delete[] should have been used. I was in a...

    yes, delete[] should have been used. I was in a hurry catching my ride down to Gothenburg (Sweden) (and it was 3:41 am). no sleep for 38 hours + stress = bad combination

    And since OP wanted to...
  13. Replies
    7
    Views
    1,128

    No, you will have to make char *route point to a...

    No, you will have to make char *route point to a location where you can write data read from stdin (std::cin)



    char *p = new char[1024];
    std::cin >> p;
    std::cout << "input: " << p <<...
  14. Replies
    7
    Views
    1,128

    you can make your std::string return a valid...

    you can make your std::string return a valid 'char *' to itself by calling it's <string>.c_str();



    std::string path ("./my_file.txt");
    std::ifstream f (path.c_str(), std::ios::binary);

    ...
  15. Thread: wat to use?

    by edoceo
    Replies
    17
    Views
    1,651

    true, but as written earlier - I'm only writing...

    true, but as written earlier - I'm only writing examples. and this time it was to show that you cannot always trust std::map's default usage of std::less - even though it can be trusted when dealing...
  16. Replies
    3
    Views
    858

    View Post

    <- slowpoke, read post above (edit)

    It is easier to read the code if you do some consistent indentation:



    do {
    db.insertionSort(); // insertion-sort...
  17. Thread: wat to use?

    by edoceo
    Replies
    17
    Views
    1,651

    Since I hardcoded this small "application" to add...

    Since I hardcoded this small "application" to add my value to '_map', and since it was only a demonstration of using std::pair as a key in a std::map I didn't see any reason to check if it was really...
  18. Thread: wat to use?

    by edoceo
    Replies
    17
    Views
    1,651

    Something like this? #include ...

    Something like this?



    #include <iostream>
    #include <utility>
    #include <string>
    #include <map>

    typedef std::pair<char,char> p_key;
  19. Thread: fork + exec

    by edoceo
    Replies
    3
    Views
    1,406

    You should close open file-descriptors that are...

    You should close open file-descriptors that are lying around.

    If this is important or not is up to you, but if your process has a lot resources open at the same time and the OS the process is...
  20. Thread: fork + exec

    by edoceo
    Replies
    3
    Views
    1,406

    Pretty much nothing. As long as you check if the...

    Pretty much nothing. As long as you check if the return-values from fork and exec~ functions are satisfying you will be alright.
    (For example, don't forget to exit the child if exec~ was...
  21. Replies
    7
    Views
    1,299

    An easy approach would be to alter your...

    An easy approach would be to alter your recursivefunction to make it work in a different way. You could, for example, do something similar to the code below. Since the function is not recursive the...
  22. Replies
    5
    Views
    864

    I'm sorry but I haven't read any C-book in my...

    I'm sorry but I haven't read any C-book in my life, so I got nothing to recommend. For me trial and error has worked fine, and I also think that it is the best way of learning.I'm not saying that...
  23. Thread: Bit operations?

    by edoceo
    Replies
    5
    Views
    1,417

    If I understand you correctly you would like to...

    If I understand you correctly you would like to do something like this(?):

    #include <stdio.h>
    #include <assert.h>

    int
    main (int argc, char **argv)
    {
    unsigned short op_code, tmp;
  24. Replies
    10
    Views
    1,385

    There are many ways of doing this. if you are...

    There are many ways of doing this. if you are looking at a school-assignment your teacher might want you to read on about loops and such. Just picture how you would do this math in your head, and...
  25. Replies
    3
    Views
    1,059

    if you are thinking of the C++ STL type...

    if you are thinking of the C++ STL type "std::map" you are in the wrong forumsection, otherwise: read on.

    tip #1
    compare parts of strings (char *):


    #include <string.h>

    char *foobar =...
Results 1 to 25 of 31
Page 1 of 2 1 2