Hello
do you know whats wrong with this code?

#include <stdio.h>
#include <allegro5\allegro5.h>
#include <allegro5\allegro_primitives.h>
#include <allegro5\allegro_image.h>

int main()
{
    al_init();
    FILE* pFile;
    return 0;
}

If I compile it, it fails and output is:
main.c
1>c:\users\beda\documents\visual studio 2010\projects\c allegro\c allegro\main.c(9): error C2143: syntax error : missing ';' before 'type'

But if I run it as C++ code (source code is called main.cpp) it runs without problems. And I am using VC++ 2010.
Thanks for help.

In C language, before version c99, you have to declare all objects at the beginning of the block. Reverse the order of lines 8 and 9 so that the declaration of pFile is the first thing in the function. C++ does not have that restriction.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.