易截截图软件、单文件、免安装、纯绿色、仅160KB

C链表问题

我输入1 但输出不是1 问一下我哪错了?主要是参数的传递出错了吧 但我怎么也看不出来 我的是地址传递
#include "stdio.h"
typedef int type;
typedef struct lnode
{
type elem;
struct lnode *next;
}linklist;
void creatlist(linklist *l)
{

l=(linklist*)malloc(sizeof(linklist));
    scanf("%d",&(l->elem));

}
void main()
{
linklist l;
        creatlist(&l);
printf("%d",l.elem);
}
#include "stdio.h"
#include "malloc.h"
typedef int type;
typedef struct lnode
{
type elem;
struct lnode *next;
}linklist;
void creatlist(linklist* &l)
{

l=(linklist*)malloc(sizeof(linklist));
scanf("%d",&(l->elem));

}
void main()
{
linklist *l;
creatlist(l);
printf("%d",l->elem);
}

虽然你传了地址进去,但是你却在那里另外申请了空间,并把数字写到那个里面去了。而输出的却是原来那个空间的elem.
去掉malloc就应该对了
C/C++ code:

#include "stdio.h"
typedef int type;
typedef struct lnode
{
type elem;
struct lnode *next;
}linkl


相关问答:

c基础

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

void main()
{
int i;
char buf[]="abcde";
strncpy(buf,"abc",3);
for(i=0;i <5;i++)
printf(&q ......

eclipse3.5+cdt编译c有问题

编译普通的c没问题啊,但编译javah生成的就报错:
gcc -O0 -g3 -Wall -c -fmessage-length=0 -oHelloWorld.o ..\HelloWorld.c
gcc -otest.exe HelloWorld.o
d:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../. ......

为什么C写DLL文件C、PB能调用VB不能调用

为什么C写的DLL文件C、PB能调用VB不能调用?
VB里为什么有的DLL直接通过引用可以使用?有的需要通过declare申明外部函数?这些DLL有什么差别?

1、为什么PB能通过DECLARE声明而VB不行?
2、如果这个dll中的 ......

一道C 题目

声明了一个整数数组  a[30]  , a 的内存地址位置为: 240ff40 
请问    a[10]  a[15] 的内存地址是什么???

详细的说明和答案 。。。我是初学者。。。在线等。。。。 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号