首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

一个很菜的有关问题

2012-02-14 
一个很菜的问题#include stdio.h#include stdio.h#include malloc.hstructstring{charchstructstri

一个很菜的问题
#include <stdio.h>
#include <stdio.h>
#include <malloc.h>

struct   string
{
char   ch;
struct   string   *   nextptr;
};

struct   string   *   create(struct   *   h);
//void   print_string(struct   string   *   h);
int   num   =   0;
int   main()
  {
struct   string   *head;
head   =     NULL;
printf( "please   input   charcter:\n ");
head   =   create(head);
//print_string(head);
printf( "\nNumber   of   charcters   =   %d ",   num);
getchar();
  return   0;
  }

struct   string   *   create(struct   string   *   h)
{
struct   string   *   p1,   *p2;
p1=p2=(struct   string   *   )malloc(sizeof(struct   string));
if(p2   !=   NULL)
{
scanf( "%c ",   &p2-> ch);
p2-> nextptr   =   NULL;
}
return   h;
}
调用CREATE函数时候为什么提示类型不匹配啊

[解决办法]
struct string * create(struct string * h);
//void print_string(struct string * h);
int num = 0;
int main()
{
struct string head;
printf( "please input charcter:\n ");
head = create(&head);
...


create 函数在做什么?

内存泄漏了 ...

热点排行