Sign in to follow this  
Kryptus

Loading a text file using stdio.h

Recommended Posts

How do I load and save a text file using the stdio.h libary? I found a few tutorials on using fstream but I'd rather use stdio first.

Share this post


Link to post
Share on other sites
You are using pure C?
IF so,you may do like this:

#include<stdio.h>

int main()
{
FILE *fptr;
if((fptr=fopen("textfile.txt","rb+"))==NULL)
{
printf("An error occured");
return 1;
}
/*Your code here*/
fclose(fptr);
return 0;
}

Share this post


Link to post
Share on other sites
I found more code samples for stdio.h out there, so I thought if I could learn it, then I would be able to understand it better, before moving onto fstream.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this