タグ

関連タグで絞り込む (1)

タグの絞り込みを解除

これはひどいとC言語に関するch1248のブックマーク (1)

  • 侍エンジニア塾のC言語のサンプルがヤバすぎる。

    C言語はもうかれこれ10年くらい書いていないけど、流石にこれはヤバい。 正直な感想として、ブランド毀損するくらいの危険性をはらんでいると思う。 当該記事からコピーしてきた。 #include <stdio.h> #include <stdlib.h> // 構造体の宣言 typedef struct { int num; char *str; } strct; int main(void) { // 実体を生成 strct *entity; // 動的メモリの確保。確保したメモリをstrct型ポインタにキャスト。 entity = (strct*)malloc(sizeof(strct)); // メンバの初期化 entity->num = 0; entity->str = (char*)malloc(sizeof(32)); // メモリに文字列を代入 sprintf(entity->s

    侍エンジニア塾のC言語のサンプルがヤバすぎる。
    ch1248
    ch1248 2018/10/17
    危ういなあ……と思いながら読んでたらsizeof(32)でファッ!?となった。
  • 1