Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.9k views
in Technique[技术] by (71.8m points)

c - '*s' is a pointer; did you mean to use '->'?

My stack_d.h file

#ifndef stack_d
#define stack_d
struct s {
    int boyut;
    int tepe;
    int dizi;
};
typedef struct s* stack;
stack * init ();
int pop(stack *);
void push (int, stack *);
void bastir(stack *);
#endif

My stack.c file

#include <stdio.h>
#include <stdlib.h>
#include "stack_d.h"
stack * init(){
    stack *s = (stack *) malloc(sizeof(stack));
    s->dizi =NULL;
    s->boyut =2;
    s->tepe=0;
    return s;
}
int pop(stack *s ){
        if (s->tepe <= s->boyut/4){

I tried this s pointer with -> but my compiler says did you mean to use ->? What should I do?

question from:https://stackoverflow.com/questions/65873617/s-is-a-pointer-did-you-mean-to-use

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

What should I do?

Remove the pointer from the typedef:

typedef struct s stack;

and your code should be fine. Do not use pointer typedefs, they are very confusing.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...