Search:

Type: Posts; User: Narf

Page 1 of 8 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    20
    Views
    2,136

    Maybe. I started when I was about 14. But I...

    Maybe. I started when I was about 14. But I couldn't stay interested enough in it at the time and didn't return to programming until a few years later.

    I've seen it in the bookstores, but haven't...
  2. Replies
    20
    Views
    6,066

    Well, you have to blame somebody for the ills of...

    Well, you have to blame somebody for the ills of the world. It's easier to complain than to fix something.
  3. Replies
    6
    Views
    2,220

    I'm dying to know how an invalid declaration...

    I'm dying to know how an invalid declaration prompted a question about memory layout.
  4. Replies
    6
    Views
    6,148

    anonytmouse didn't make a typo. He really did...

    anonytmouse didn't make a typo. He really did mean sscanf() as opposed to scanf(). You can see the differences here. scanf() reads from a stream but sscanf() reads from a string.
  5. Replies
    8
    Views
    3,143

    So use a number: int num; if (scanf("%d",...

    So use a number:


    int num;

    if (scanf("%d", &num) == 1 && num >= 0 && num <= 90)
    printf("%d is valid\n", num);
  6. Replies
    4
    Views
    2,023

    That's not gonna happen. Sorry, but this reeks of...

    That's not gonna happen. Sorry, but this reeks of homework and if we gave you the code then you wouldn't learn anything. But here's a hint: Reverse each word, then reverse the whole string. You can...
  7. Replies
    17
    Views
    2,486

    Well naturally it's not portable. Presumably...

    Well naturally it's not portable. Presumably bhuwan already knows that it works on his system, or he'll be back shortly to ask why it doesn't work. :)
  8. Replies
    17
    Views
    2,486

    It's pretty straightforward. You cast the...

    It's pretty straightforward. You cast the address--as a literal value--to a pointer of suitable type for how you're going to use it. The pointer then points to that address and you can use it just...
  9. Replies
    17
    Views
    2,486

    Something like this: volatile unsigned char...

    Something like this:


    volatile unsigned char *addr = (unsigned char *)0x80000000;
  10. Thread: STRTOK SegFaults!

    by Narf
    Replies
    3
    Views
    2,017

    The problem isn't about type. cSM is the right...

    The problem isn't about type. cSM is the right type, but it points to memory that you can't modify. To fix the problem you need to copy the string into memory that you own so that strcpy() can safely...
  11. Thread: STRTOK SegFaults!

    by Narf
    Replies
    3
    Views
    2,017

    cSM is set to a string literal. strtok modifies...

    cSM is set to a string literal. strtok modifies the string you pass to it, and you can't safely modify a string literal because it could be in read-only memory.
  12. Pre-C99 code would do it like this: #include...

    Pre-C99 code would do it like this:


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

    struct test {
    int a[1];
    };
  13. Replies
    9
    Views
    3,258

    What kind of games? You can write a game after...

    What kind of games? You can write a game after about 30 minutes of practice with C++. But if you're talking about what most people think of as games, you need to know more than just language features...
  14. Thread: searching problem

    by Narf
    Replies
    9
    Views
    7,504

    If you store the data the right way, efficient...

    If you store the data the right way, efficient search becomes a non-issue.

    Probably not, but you're not explaining the problem to the point where I can fully understand what you're doing. I don't...
  15. Replies
    7
    Views
    1,362

    If you're not sure what it does, you really...

    If you're not sure what it does, you really shouldn't be using it. ;)

    Your best bet is to avoid passing 0 to malloc() in the first place. It's an easy case to test for, or you can write your code...
  16. Thread: searching problem

    by Narf
    Replies
    9
    Views
    7,504

    Can you store extra information in the data...

    Can you store extra information in the data structure or create a helper data structure? If I understand your problem then you can just store the partition number for each point with that point and...
  17. Replies
    26
    Views
    2,986

    Well I would, if there were something to laugh...

    Well I would, if there were something to laugh at. By the way, I have a way to call malloc() that's easier to get right:


    char*compare=(char*)malloc(sizeof(char*)*20);...
  18. Replies
    26
    Views
    2,986

    Your compare variable is a pointer, but...

    Your compare variable is a pointer, but ReadCatalogue expects a pointer to a pointer. Change the call to this and see how it works:


    ReadCatalogue(myfile,*choice,&compare);
  19. Replies
    6
    Views
    2,211

    You call the default constructor explicitly, then...

    You call the default constructor explicitly, then pass it as a return value where the copy constructor is called implicitly behind the scenes. Just because a compiler might implement return value...
  20. Replies
    3
    Views
    2,714

    None that are worth the money they ask you for it.

    None that are worth the money they ask you for it.
  21. Replies
    6
    Views
    2,211

    The one that I've colored red for you: class...

    The one that I've colored red for you:


    class C
    {
    public:
    explicit C() {};
    explicit C(const C& c) {};
    ~C() {};
    };
  22. Replies
    6
    Views
    2,211

    A constructor only needs to be qualified as...

    A constructor only needs to be qualified as explicit if it takes a single argument and you don't want implicit conversions to be made. You want implicit conversions with the copy constructor, or...
  23. Replies
    5
    Views
    1,404

    Which is irrelevant with inclusion guards because...

    Which is irrelevant with inclusion guards because you only need one unique identifier per header. In general I agree that defined() is more flexible, but for inclusion guards I don't see the need.
    ...
  24. Replies
    25
    Views
    2,048

    And the actual standard says: Where the...

    And the actual standard says:

    Where the footnote 253 is exceptionally clear:
  25. Replies
    25
    Views
    2,048

    I didn't comment it out, I just commented that it...

    I didn't comment it out, I just commented that it wasn't a good idea:


    // memset() probably isn't a good idea
    memset(tmp->ptr, 0, sizeof *tmp->ptr);

    If I knew the declaration of DFNCOL then I...
Results 1 to 25 of 176
Page 1 of 8 1 2 3 4