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

Categories

when compiled i am receiving the above error, what might be the possible cause of this error. I was expecting 65 0 as the output!

int main(){
    char c, *cptr;
    void v, *vptr;
    c = 65; v = 0;
    cptr = &c; vptr = &v;
    printf(“ % d % d”, *cptr, *vptr);
}
question from:https://stackoverflow.com/questions/66062035/variable-has-incomplete-type-void

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

1 Answer

  • void means "no data", so declaring a variable with type void makes no sense. You should use an integer type.
  • You didn't include required header.
  • Your format string is wrong (at least non-standard).

Try this:

#include <stdio.h>

int main(void){
    char c, *cptr;
    int v, *vptr;
    c = 65; v = 0;
    cptr = &c; vptr = &v;
    printf("%d %d", *cptr, *vptr);
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...