Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-13-2002, 09:45 AM   #1
Registered: May 2001
Posts: 125

Rep: Reputation: 15
Writing encrytped data to a disk

I am writing a program that writes encrypted data to a file. i am worried that one of the encrypted strings might carry the EOF charachter in it and prematurely end the file. Is there a way i can avoid this? thank you
Old 04-13-2002, 05:48 PM   #2
LQ Newbie
Registered: Apr 2002
Posts: 2

Rep: Reputation: 0
Thumbs up No Problem

The EOF character is only a reading concept for some file input fuctions which return characters one at a time. For instance if you use fgetc and it returns you the EOF character, you might be at the end of the file but you will not know until you check with a call to feof. Reading EOF from a file is not a problem when using functions like fread, it's just another character.

#include <stdio.h>
#include <stdlib.h>

int main()
char buff[100] = { '\0' };
FILE *fp;
fp = fopen("blahblah","w");
fprintf(fp,"Hello%c World\n",EOF);
fp = fopen("blahblah");
Old 04-17-2002, 11:18 PM   #3
Registered: Feb 2002
Location: Mission Viejo, California, USA
Distribution: Gentoo
Posts: 707

Rep: Reputation: 30
The filesystem knows where EOF is based on the *length* of the file, not on data inside the file.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
writing raw data to a tiff file James_dean Programming 4 10-25-2005 05:03 AM
writing encrypted data to disk rblampain Linux - Security 14 07-31-2005 11:38 PM
Error 5 in Kb3 writing Windows Data Chems Linux - Newbie 1 09-11-2004 10:34 AM
CD RW -- Writing Data to CD dnachtwey Linux - Hardware 39 01-25-2004 06:22 PM
perl - writing a data structure to a file.. is it possible? paavaka Programming 4 07-14-2001 12:04 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:56 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration