Search:

Type: Posts; User: laserlight

Page 1 of 20 1 2 3 4

Search: Search took 0.19 seconds.

  1. I'd say no: you do have to define two in the same...

    I'd say no: you do have to define two in the same translation unit as one in order for it to be static/have internal linkage and yet called by one. A compromise solution might be to make use of a...
  2. This is wrong because you have a local variable...

    This is wrong because you have a local variable for the new local: that variable ceases to exist after the function returns. You could make it static, but then all you'll ever have is one variable,...
  3. What is a "pattern"?

    What is a "pattern"?
  4. Replies
    27
    Views
    468

    I don't see why that is so.

    I don't see why that is so.
  5. Replies
    27
    Views
    468

    That's great! If we apply what you wrote to your...

    That's great! If we apply what you wrote to your more complex problem with linked lists though, what you're doing is equivalent to doing deep copying. Granted, in this simplified version it is...
  6. Replies
    27
    Views
    468

    So what I am suggesting is this: attempt a...

    So what I am suggesting is this: attempt a simpler version of what you're trying to solve, and show us how you do it. Forget about linked lists for now, and focus on the notion of implementing...
  7. You're right: they match. It may make no...

    You're right: they match.

    It may make no difference, but I suggest that you remove the using declaration from the header file: fully qualify std::string there instead. In the source file, move the...
  8. Replies
    27
    Views
    468

    Wait. This is an extremely simple version of the...

    Wait. This is an extremely simple version of the complex problem that you're trying to solve. If you cannot implement the simple version, then you have no hope of implementing the complex version, so...
  9. Replies
    27
    Views
    468

    Great, that's good information to work with....

    Great, that's good information to work with. Let's simplify and imagine that you're dealing with this number type:

    typedef struct number
    {
    int value;
    } number;

    number *add(number *x,...
  10. Replies
    27
    Views
    468

    The first thing that I suggest is for you to get...

    The first thing that I suggest is for you to get rid of those typedefs, i.e., this:

    typedef struct node { double coefficient, power;
    struct node *Previous, *Next;
    } *equationList;
    ...
  11. Replies
    27
    Views
    468

    Sure, but you'll have to post the code here. ...

    Sure, but you'll have to post the code here.

    I don't see what's so difficult though. You already have an idea of how identify whether you need to copy, i.e., ask yourself if you need the original...
  12. Replies
    27
    Views
    468

    Maybe, maybe not. It depends on your...

    Maybe, maybe not. It depends on your requirements. For example, suppose that you want to operate on a linked list, thereby changing it, but you also want to retain the original state of the linked...
  13. Replies
    27
    Views
    468

    So, you want to pass the linked list to a...

    So, you want to pass the linked list to a function and modify it while keeping it unmodified in the caller. This means that you must make a copy of the linked list so that you can modify the copy,...
  14. Replies
    27
    Views
    468

    This is wrong: struct node *L = (struct node...

    This is wrong:

    struct node *L = (struct node *)malloc(sizeof(struct node*));
    It should be:

    struct node *L = malloc(sizeof(*L));
    That is, you were allocating space for a pointer when you want...
  15. Replies
    27
    Views
    468

    If the linked list is represented by a pointer to...

    If the linked list is represented by a pointer to the head node only, then pass a pointer to that head node. You may need to return a pointer to the resulting head node, or pass a pointer to a...
  16. You might want to revise your learning material...

    You might want to revise your learning material on pre-increment versus post-increment; you may have mixed them up hence the confusion.
  17. Replies
    7
    Views
    341

    You just haven't found it yet. What IDE and/or...

    You just haven't found it yet. What IDE and/or compiler are you using?


    Try to compile this program:

    #include <stdio.h>

    int main(void)
    {
    printf("hello
  18. Remember, the first identifier is the macro name,...

    Remember, the first identifier is the macro name, and the rest is what the macro consists of. So, this doesn't set the LED_Set macro; this sets the LED_Off macro to LED_Set. This way, you can use the...
  19. Replies
    7
    Views
    341

    ... but not at the same time. You have to pick a...

    ... but not at the same time. You have to pick a language: do you want to write this program in C or in C++?

    Also, read Stroustrup's answer to the FAQ: What do you think of C/C++?

    As for the...
  20. Replies
    2
    Views
    258

    It doesn't look like you have a dynamic array:...

    It doesn't look like you have a dynamic array: you allocated space for just one music object.

    I'd get rid of the countLines function: you can count while reading, and you should only do so once.
  21. You could have a buffer overflow elsewhere that...

    You could have a buffer overflow elsewhere that is corrupting memory, and so it looks like the problem is with this function when it is actually elsewhere.
  22. You have to recognise that in this function: ...

    You have to recognise that in this function:

    void foo(char s[10]) {}
    The parameter named s is a pointer, not an array. The 10 indicates that the pointer is expected to point to the first char in...
  23. Replies
    1
    Views
    272

    To check precedence, just search for a draft of...

    To check precedence, just search for a draft of the C standard, and look at the section on expressions. You'll find that these two operators have the same precedence, and the grammar indicates...
  24. Replies
    2
    Views
    338

    Calling strncat in a loop like that is rather...

    Calling strncat in a loop like that is rather inefficient since strncat has to find the end of the string and then append to it, plus using strncat with a lone char like that looks rather...
  25. Replies
    9
    Views
    503

    You have two ofstream objects: outputFile and fs....

    You have two ofstream objects: outputFile and fs. You only have one output file. Pick one. That is, if you want to use outputFile, then delete fs. If you want to use fs, then delete outputFile. What...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4