Search:

Type: Posts; User: creek23

Search: Search took 0.00 seconds.

  1. Replies
    19
    Views
    5,080

    Finally wrote the function I wanted to make with...

    Finally wrote the function I wanted to make with help of pass-by-reference.

    The code below would allow to load a ASCII file content (hopefully with binary file too) into an uninitialized string.
    ...
  2. Replies
    19
    Views
    5,080

    Thanks Salem! That was actually helpful. Here's...

    Thanks Salem! That was actually helpful. Here's the working code below.




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

    void my_strcpy(char **dest, char *src) {
    *dest = (char *)...
  3. Replies
    19
    Views
    5,080

    Saying there is none and saying you can simulate...

    Saying there is none and saying you can simulate it is a contradicting statement. Just as saying there no pointers in Java but you can fake one.

    Of course, I'm aware that C uses pointers to fake...
  4. Replies
    19
    Views
    5,080

    already added 1 -> malloc(sizeof(strlen(src) +...

    already added 1 -> malloc(sizeof(strlen(src) + 1));

    still the same. app crashes. :(
  5. Replies
    19
    Views
    5,080

    I actually just forgot the **. edited the post,...

    I actually just forgot the **. edited the post, please check again.
  6. Replies
    19
    Views
    5,080

    I'm actually not after the replication of the...

    I'm actually not after the replication of the functionality of strcpy nor strdup. I'm after the passing-by-reference in C.

    Exactly how do I do that? I'm getting segmentation fault with this test....
  7. Inter-dependent structs for doubly-linked list

    I'm trying to implement a different kind of doubly-linked list. It's made up of 2 different structs that are inter-dependent.




    typedef struct {
    int value;
    Child *child;
    } Parent;
  8. Replies
    19
    Views
    5,080

    how to retain an allocated memory

    I'm trying to make my own strcpy. A version of strcpy that will allow this,



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

    int main(void) {
    char *content1;
  9. Replies
    10
    Views
    3,883

    cool! thanks for correcting me. and for a...

    cool!

    thanks for correcting me. and for a snippet on testing memory leaks. ;)

    thanks.
  10. Replies
    10
    Views
    3,883

    Thanks Bayint Naung. I edited the code and it...

    Thanks Bayint Naung. I edited the code and it does work with only Foo *foo and not Foo **foo, thus no need to malloc both array instance.




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

    typedef...
  11. Replies
    10
    Views
    3,883

    Thanks Bayint Naung. I edited the code and it...

    Thanks Bayint Naung. I edited the code and it does work with only Foo *foo and not Foo **foo, thus no need to malloc both array instance.




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

    typedef...
  12. Replies
    10
    Views
    3,883

    hmm... let me take a look at it again. thanks for...

    hmm... let me take a look at it again. thanks for the tip.
  13. Replies
    10
    Views
    3,883

    well, you could. as long as the char pointer has...

    well, you could. as long as the char pointer has memory allocated of just about the same size of the string value being assigned.

    in it's simplest form:



    #include <stdio.h>

    int main() {
    ...
  14. Replies
    10
    Views
    3,883

    whoopie! got it! changed .value to ->value. ...

    whoopie! got it! changed .value to ->value.



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

    typedef struct {
    int etc1;
    char *value;
  15. Replies
    23
    Views
    4,233

    Try releasing it in LGPL license, so anyone who...

    Try releasing it in LGPL license, so anyone who will use and made fixes and additional functionality will have to re-release the _updated_ one.
  16. Replies
    10
    Views
    3,883

    oops. That was just an error in my attempt to...

    oops.

    That was just an error in my attempt to simplify what I'm currently working on. It should have been

    bar.foo[0].value = (char *) malloc(sizeof("howdy"));
    bar.foo[0].value = "howdy";...
  17. Replies
    10
    Views
    3,883

    accessing struct element from another struct

    Hello, I'm not new to programming. I've been developing games with BASIC (FreeBASIC), and Flash games with ActionScript. I even developed a scripting language for beginning programmers to make games....
Results 1 to 17 of 17