" 'FILE' not declared in this scope"

This is a discussion on " 'FILE' not declared in this scope" within the C++ Programming forums, part of the General Programming Boards category; I'm getting the error " 'FILE' not declared in this scope" many times while compiling my program, as well as ...

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    14

    " 'FILE' not declared in this scope"

    I'm getting the error " 'FILE' not declared in this scope" many times while compiling my program, as well as " 'FILE' does not name a type" twice. I think one may be a product of the other.

    Here's one line i'm getting the first error on:
    Code:
    FILE* open(const char filename[]){
    (I think that's the right line; compiler says "ISBNPrefix.h:16:18:", and that's line 16.)

    Please advise. Let me know if you need more info; I don't wanna post my code if unnecessary.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    Somewhere you need
    #include <stdio.h>
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Nov 2010
    Posts
    14
    I have
    Code:
    #include<iostream> 
    #include<cstring>
    #include<cstdlib>
    #include<stdio.h>
    included on one .cpp, and
    Code:
    #include<string.h>
    #include<cstring>
    #include<iostream> 
    #include<cstdlib>
    #include<stdio.h>
    on the other.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    Well we're not going to be able to tell from 1 line of code.

    > I think that's the right line; compiler says "ISBNPrefix.h:16:18:", and that's line 16.)
    The first 20 lines of this file perhaps.

    Why do you have code inside a .h file?

    Is stdio.h included BEFORE this file?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Nov 2010
    Posts
    14
    Woops, I read 'ISBNPrefix" but didn't think to check whether it was the .h or .cpp; the line I gave before was wrong, then.

    ISBNPrefix.h is short, minus comments, so I'll post the whole thing.

    Code:
    FILE* open(const char filename[]);
    
    int isRegistered(FILE* fp, int area); //With comments in, this one's line 16
    
    int minNoDigits(FILE* fp, int area);
    
    int isRegistered(FILE* fp, int area, const char publisher[]);
    
    int close(FILE* fp);
    >Why do you have code inside a .h file?
    I don't, it's only (what's the term for placeholder function definitions, again?)s.

    >Is stdio.h included BEFORE this file?
    Should it be? That's probably my problem, right there.

    Edit: Yeah, it was. Thanks!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 11-11-2010, 11:05 AM
  2. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  3. Newbie homework help
    By fossage in forum C Programming
    Replies: 3
    Last Post: 04-30-2009, 04:27 PM
  4. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 01:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21