Thread: Dev-Cpp doesn't understand the data type FILE

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    46

    Dev-Cpp doesn't understand the data type FILE

    When i type FILE as a datatype to make progs working on some files dev-cpp doesn't change it into bold as does with int float double........etc and when i run the prog it doesn't work ofcourse.

  2. #2
    Registered User
    Join Date
    Sep 2003
    Posts
    224
    Are you doing a C++ program? If so, you have to #include <stdio.h>

  3. #3
    Registered User TactX's Avatar
    Join Date
    Oct 2005
    Location
    Germany.Stuttgart
    Posts
    65
    Syntax highlighting only works for stuff like keywords, #define, strings and such. FILE is a typedef (not a keyword). But that does not explain why the code won't compile (or run). Have you included stdio.h? What error messages do you get?

  4. #4
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,732
    this programe was compiled on DEV C++ complier it works fine for me, as TactX said only reserve words are highlighted
    Code:
    #include <stdio.h>
    
    int main()
    {
        FILE *fp;
        
        fp = fopen("snake.txt","r+");
        
        if(fp)
        {
            printf("The file opened with no error!!!");
            getchar();
        }
        else
        {
            printf("Error: File cannot be opened");
            getchar();
            return 1;
        }
        
        return 0;
    }
    
    /*myoutput
    The file opened with no error!!!
    */
    NOTE: some compilers does something like what u want but not all like DEV C++

    ssharish2005

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  2. Replies: 2
    Last Post: 04-09-2006, 07:20 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Erros in Utility Header File
    By silk.odyssey in forum C++ Programming
    Replies: 4
    Last Post: 12-22-2003, 06:17 AM