Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


FILE data type?

FILE data type?

FILE data type?

Hi there,
I've got some C experience, but not a ton. I'm working on integrating a library of C code into a C project that I'm writing, but I'm stumbling on supplying a required argument because I don't have the right data type. The function signature is

static void blockPrint (FILE *fp, const BYTE *block, int blockBits, const char *tag)

It's the first argument that I'm not getting. In the example code for this function, a regular string is being sent to this function (i.e. "file.txt"), but in my code I have the file path in question supplied as a const char *. But what the heck is a var of type FILE? I can't find this anywhere in Google or the C docs.

I'm guessing this is a total n00b question, but a little help would... uh, help.


RE: FILE data type?

Ah, good search! That did it. For the kids at home, the FILE type actually requires a connected resource via the fopen() call. So you can't simply declare a variable of type FILE; you have to then use it to open a file.

FILE *realFile = fopen(theFile, "r");
blockPrint(realFile, block, BITSPERBLOCK, "PT");


RE: FILE data type?

Strictly speaking, in C the FILE type is a library defined (in stdio.h header) type alias (see typedef keyword). No need to use FILE type as such, only FILE* (pointer to FILE) type. It's (one of;) C language funny idioms.
As usually, FILE type alias denotes library defined structure, but don't use its members directly (it's implementation dependent entity).

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close