Visual Studio "illegal use of this type as an expression"

I just started using Visual Studio (I got VS 2012 from dreampark, and I haven't started using Windows for a long time) and I'm having problems.

I have one file named "main.c" in the "Source Files" folder, which looks like this:

#include <stdio.h>

typedef struct S_s S;
struct S_s {
    void* x;
};

int main(int argc, char** argv)
{
    int N;
    scanf("%d", &N);

    S* s;
    printf("%p", s);

    return 0;
}

And when I try to build, it gives me the following error messages:

Error   3   error C2065: 's' : undeclared identifier    c:\users\math4tots\documents\visual studio 2012\projects\algorithms\lecture1\main.c 13  1   Lecture1
Error   4   error C2065: 's' : undeclared identifier    c:\users\math4tots\documents\visual studio 2012\projects\algorithms\lecture1\main.c 14  1   Lecture1
Error   2   error C2275: 'S' : illegal use of this type as an expression    c:\users\math4tots\documents\visual studio 2012\projects\algorithms\lecture1\main.c 13  1   Lecture1

The funny thing is that it builds fine if I comment out a line scanf.

I created an "empty project" in the "Visual C ++" options, so I was not sure that VS compiled it as a program in C or C ++. However, I had the impression that my code was quite committing for C / C ++, which should compile in either C or C ++.

, , ?

+5
2

++ C99, C89. C89 , S* s; scanf("%d", &N); C89 .

+14

, C ( C99) . scanf S* s . scanf "" . ++.

+5

All Articles