Search:

Type: Posts; User: john.c

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    12
    Views
    106

    Great points. I forgot all about the destructor...

    Great points. I forgot all about the destructor calls (when appropriate) and the non-binding nature of shrink_to_fit(). Just goes to show how memory management is pretty complicated.
    Thanks...
  2. Replies
    8
    Views
    160

    The linker knows nothing about .h files. The .c...

    The linker knows nothing about .h files.
    The .c files are turned into .o (object) files.
    The linker only deals with object files (and libraries of those).
    The object files contain missing...
  3. Replies
    12
    Views
    106

    If you stored a million ints in a vector and then...

    If you stored a million ints in a vector and then cleared it, it would be pretty arbitrary for the system to "deallocate" the memory since, as far as it knows, you may be about to fill it up again...
  4. Replies
    12
    Views
    106

    Exactly. There's the shrink_to_fit() method for...

    Exactly. There's the shrink_to_fit() method for actually returning memory back to the allocator (although it probably won't return it back to the operating system, since that's pretty much pointless).
  5. Replies
    8
    Views
    160

    The linker doesn't see .h files. :)

    The linker doesn't see .h files. :)
  6. Replies
    12
    Views
    106

    No it doesn't. That was my point. :) Although I...

    No it doesn't. That was my point. :)
    Although I could've made it better by printing the capacity after the clear().
  7. Replies
    12
    Views
    106

    It probably just sets the size member to 0. Try...

    It probably just sets the size member to 0. Try this. It prints 3 for me, even though the vector was "cleared".


    #include <iostream>
    #include <vector>

    int main() {
    std::vector<int> v;
    ...
  8. The program is badly structured. Your "readline"...

    The program is badly structured.
    Your "readline" routine should just, you know, read a line.
    Then you can pass it to another function to do whatever it is you are trying to do (which I can't quite...
  9. buffer[i] makes no sense here. In fact, i itself...

    buffer[i] makes no sense here.
    In fact, i itself makes no sense.
    What are you trying to do here?

    And, technically, invalid_characters should be const. (And spelled consistently!)
  10. Replies
    1
    Views
    97

    IMO, it would be pretty pointless to constantly...

    IMO, it would be pretty pointless to constantly check for NULL pointers and return some kind of code to the caller in every function that receives a pointer. The caller can ensure his inputs are not...
  11. Replies
    2
    Views
    103

    The compiler acts as if it redefines the variable...

    The compiler acts as if it redefines the variable every loop iteration, but it doesn't necessarily do it that way. At a high enough optimization level, it will probably notice that the entire loop...
  12. Replies
    10
    Views
    157

    I'm wondering if he was supposed to use the...

    I'm wondering if he was supposed to use the "boardGame" class in making the new class. I don't think inheritance would be correct, but maybe something like:


    class tdBoard {
    boardGame bg[3];...
  13. Replies
    6
    Views
    113

    Yes, they are all the same. The point is that you...

    Yes, they are all the same. The point is that you can pass the exact same array to all of them. The last version is just explicitly saying what is actually happening. The other two are in a sense...
  14. Replies
    6
    Views
    113

    Do you understand that these all say essentially...

    Do you understand that these all say essentially the same thing?


    void f(char matrix3d [10][20][30]);
    void g(char matrix3d [ ][20][30]);
    void h(char (*matrix3d) [20][30]);

    When you...
  15. Replies
    6
    Views
    108

    head is a pointer variable that initially holds...

    head is a pointer variable that initially holds the address of the current first node, which will be NULL (basically zero) if the list is empty.

    The newly created node's next pointer is set to...
  16. Replies
    5
    Views
    168

    I think this is what you are trying to do. ...

    I think this is what you are trying to do.


    #include <stdio.h>
    #include <stdlib.h>
    #include <stdbool.h>
    #include <string.h>

    #define EXTEND_SIZE 256
  17. Replies
    5
    Views
    168

    If you're still having problems, post a complete...

    If you're still having problems, post a complete program that I can run.
    Also post the input.
  18. Replies
    10
    Views
    157

    This code is pretty senseless, actually. Why is...

    This code is pretty senseless, actually.
    Why is tdBoard derived from boardGame?
    It's not using any of it's functionality or data at all!
    You could delete 150+ lines and the program would be...
  19. Replies
    18
    Views
    299

    Oh, you're right. Except that the way we would...

    Oh, you're right. Except that the way we would usually handle it is by adding an extra space (just a space, not a newline) in front of the format of your other scanf.


    int len = 0;
    ...
  20. Replies
    18
    Views
    299

    You shouldn't have the newline character in that...

    You shouldn't have the newline character in that scanf format. It should just be:


    scanf("%d", &len);
  21. Replies
    2
    Views
    89

    I'm not sure what you're getting at. Both of...

    I'm not sure what you're getting at. Both of those seems to "work".

    However, if you mean to only allow decimal input for the integer then it's better to use %d instead of %i since %i accepts...
  22. Replies
    14
    Views
    310

    Thanks man. You didn't do anything wrong at all....

    Thanks man. You didn't do anything wrong at all. (I really was cranky, complete with headache!)
  23. Replies
    14
    Views
    310

    The basic meaning of + is not an overload and...

    The basic meaning of + is not an overload and they are definitely intrinsic to the compiler. They are pretty much just single assembly code instructions since the basic types correspond generally to...
  24. Replies
    2
    Views
    89

    This works for me (in C++14 so that the binary...

    This works for me (in C++14 so that the binary literals are legal) :


    #include <iostream>
    #include <bitset>


    using State = std::bitset<4>;

    struct Person {
  25. Replies
    4
    Views
    118

    @Zeus, perhaps if you don't know anything about a...

    @Zeus, perhaps if you don't know anything about a topic you can just shut the f up? He can use google himself.

    At any rate, in C "generic data structure" can mean a couple of different things. It...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4