结构指针返回DMA地址

时间:2017-04-13 18:46:30

标签: c pointers struct

var layout = services.layout
var s = layout.getElement("searchRow")
var c = layout.getElement("consoleRow")
var cp = c.parentNode
var h = layout.getElement("hboxMain")
var hp = h.parentNode

cp.removeChild(c)
s.parentNode.removeChild(s)
cp.insertBefore(s, cp.firstChild)
hp.removeChild(h)
hp.appendChild(c)
c.insertBefore(h, c.firstChild)

错误:

str3.c:在函数'main'中: str3.c:15:14:错误:解除引用不完整类型'struct st'的指针  的scanf("%S",&安培;对 - >名称);               ^ str3.c:在函数'call'中: str3.c:25:22:错误:'sizeof'无效应用于不完整类型'struct st'  return malloc(sizeof(struct st));

1 个答案:

答案 0 :(得分:0)

1)您必须添加括号scanf("%d", &p->rollno) - > scanf("%d", &(p->rollno))

2)但是你在阅读字符串

时不需要括号

输出:

enter roll no.
1
enter name
stackoverflow 
enter marks
3.14
1 stackoverflow 3.140000

代码:

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

struct st
{
    int     rollno;
    char    name[256];
    float   marks;
};

struct st   *call(void)
{
    return malloc(sizeof(struct st));
}

int         main()
{
    struct st   *p;

    p = call();

    printf("enter roll no.\n");
    scanf("%d", &(p->rollno));

    printf("enter name\n");
    scanf("%s", p->name);


    printf("enter marks\n");
    scanf("%f", &(p->marks));

    printf("%d %s %f\n", p->rollno, p->name, p->marks);
}