senooken JP Social
  • FAQ
  • Login
senooken JP Socialはsenookenの専用分散SNSです。
  • Public

    • Public
    • Network
    • Groups
    • Popular
    • People

せのお (妹尾 賢) (senooken@social.senooken.jp)'s status on Tuesday, 18-Sep-2018 20:15:27 JST

  1. せのお (妹尾 賢) (senooken@social.senooken.jp)'s status on Tuesday, 18-Sep-2018 20:15:27 JST せのお (妹尾 賢) せのお (妹尾 賢)
    今日詰まったこと。
    C言語の引数のアドレスを変更できなかった。こんな感じで,引数に渡したポインターに別のポインターを渡して,出力結果を渡そうとしたのだけど,だめだった。memcpyしたらいけたのだけど。なぜダメなのかがわからなかった。アドレスを書き換えたらダメなんだったたっけ?いや,でも引数にポインターを渡してそれを書き換えるというのはよくやるだろう?なぜだろう。
    ```
    #include <stdio.h>
    #include <string.h>

    struct st {
    int a;
    int b;
    };

    struct st stg = {1, 2};

    void init( struct st *str) {
    str = NULL;
    printf("%d, %d\n", stg.a, stg.b );
    // memcpy(str, &stg, sizeof(stg));
    str = &stg
    }

    int main(void) {
    struct st st1 = {0};
    printf("%d\n", st1.a);
    init( &st1 );
    printf("%d\n", st1.a);
    return 0;
    }
    ```
    In conversation Tuesday, 18-Sep-2018 20:15:27 JST from web permalink

Feeds

  • Activity Streams
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

senooken JP Social is a social network, courtesy of senooken. It runs on GNU social, version 2.0.2-beta0, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All senooken JP Social content and data are available under the Creative Commons Attribution 3.0 license.