/*
http://t...content-available-to-author-only...h.net/test/read.cgi/tech/1357748713/423
423 名前:デフォルトの名無しさん [sage]: 2013/01/28(月) 15:01:31.14
[1] 授業単元:プログラミング実習
[3] 環境
[3.1] OS: Linux
[3.2] コンパイラ名とバージョン: gcc
[3.3] 言語: C
[4] 期限: 1月30日
[5] その他の制限: (どこまで習っているか、標準ライブラリは使ってはいけない等々)
・線形リストを用いてデータ
Idがうまく表示できなくて困ってます。
よろしくお願いします
*/
#include <stdio.h>
#include <stdlib.h>
#define D_N 3
typedef struct _DATA
{
int Id;
struct _DATA *pNext;
} DATA;
int main ()
{
DATA *root = NULL, *p, **pp;
int i;
// set
pp = &root;
for (i = 0; i < D_N; i++)
{
if (NULL
== (*pp
= (DATA
*) malloc (sizeof (DATA
)))) {
}
(*pp)->Id = i;
(*pp)->pNext = NULL;
pp = &((*pp)->pNext);
}
// print
for (p = root; p; p = p->pNext)
{
}
// end
for (p = root; p; p = root)
{
root = p->pNext;
}
return 0;
}
LyoKICAgIGh0dHA6Ly90Li4uY29udGVudC1hdmFpbGFibGUtdG8tYXV0aG9yLW9ubHkuLi5oLm5ldC90ZXN0L3JlYWQuY2dpL3RlY2gvMTM1Nzc0ODcxMy80MjMKICAgIDQyMyDlkI3liY3vvJrjg4fjg5Xjgqnjg6vjg4jjga7lkI3nhKHjgZfjgZXjgpMgW3NhZ2Vd77yaIDIwMTMvMDEvMjgo5pyIKSAxNTowMTozMS4xNAogICAgWzFdIOaOiOalreWNmOWFg++8muODl+ODreOCsOODqeODn+ODs+OCsOWun+e/kgogICAgWzNdIOeSsOWigwogICAgICBbMy4xXSBPU++8miBMaW51eAogICAgICBbMy4yXSDjgrPjg7Pjg5HjgqTjg6nlkI3jgajjg5Djg7zjgrjjg6fjg7PvvJogZ2NjCiAgICAgIFszLjNdIOiogOiqnu+8miBDCiAgICBbNF0g5pyf6ZmQ77yaIDHmnIgzMOaXpQogICAgWzVdIOOBneOBruS7luOBruWItumZkO+8miAo44Gp44GT44G+44Gn57+S44Gj44Gm44GE44KL44GL44CB5qiZ5rqW44Op44Kk44OW44Op44Oq44Gv5L2/44Gj44Gm44Gv44GE44GR44Gq44GE562J44CFKQogICAg44O757ea5b2i44Oq44K544OI44KS55So44GE44Gm44OH44O844K/CgogICAgSWTjgYzjgYbjgb7jgY/ooajnpLrjgafjgY3jgarjgY/jgablm7DjgaPjgabjgb7jgZnjgIIKICAgIOOCiOOCjeOBl+OBj+OBiumhmOOBhOOBl+OBvuOBmQogKi8KI2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCiNkZWZpbmUgRF9OICAgICAzCgp0eXBlZGVmIHN0cnVjdCBfREFUQQp7CiAgaW50IElkOwogIHN0cnVjdCBfREFUQSAqcE5leHQ7Cn0gREFUQTsKCmludCBtYWluICgpCnsKICBEQVRBICpyb290ID0gTlVMTCwgKnAsICoqcHA7CiAgaW50IGk7CgogIC8vIHNldAogIHBwID0gJnJvb3Q7CiAgZm9yIChpID0gMDsgaSA8IERfTjsgaSsrKQogICAgewogICAgICBpZiAoTlVMTCA9PSAoKnBwID0gKERBVEEgKikgbWFsbG9jIChzaXplb2YgKERBVEEpKSkpCiAgICAgICAgewogICAgICAgICAgZXhpdCAoMSk7CiAgICAgICAgfQogICAgICAoKnBwKS0+SWQgPSBpOwogICAgICAoKnBwKS0+cE5leHQgPSBOVUxMOwogICAgICBwcCA9ICYoKCpwcCktPnBOZXh0KTsKICAgIH0KICAvLyBwcmludAogIGZvciAocCA9IHJvb3Q7IHA7IHAgPSBwLT5wTmV4dCkKICAgIHsKICAgICAgcHJpbnRmICgiJWQgIiwgcC0+SWQpOwogICAgfQogIHByaW50ZiAoIlxuIik7CiAgLy8gZW5kCiAgZm9yIChwID0gcm9vdDsgcDsgcCA9IHJvb3QpCiAgICB7CiAgICAgIHJvb3QgPSBwLT5wTmV4dDsKICAgICAgZnJlZSAocCk7CiAgICB9CiAgcmV0dXJuIDA7Cn0K