Re: write



On Mon, 28 Apr 2008 00:39:28 GMT, "Bill Cunningham" <nospam@xxxxxxxxx>
wrote:


"Bill Waddington" <william.waddington@xxxxxxxxxx> wrote in message
news:c75a149109g74qhdr6tiqd9i9jkh61jvaq@xxxxxxxxxx

What does file say if you call write thusly:

if((t=write(file,buf,7))==-1) {

Just curious,
Bill

Just like I thought. Just enough space for the string "string\0" String
and the terminating \0. I changed it to strlen though.

But what kind of file does the file utility think it is?

My (implied) point was that you were writing more than just your
text string by passing in a byte count larger than your string.
You were writing the string plus whatever followed it in memory.

Depending on the additional stuff you wrote, file may well
have decided that it _wasn't_ a text file. It may be that
including the \0 at the end of your string will also cause
file to decide that it's a data file rather than a text file.

AFAIK, file just looks at the _contents_ of a file and takes
its best shot at determining what it is.

I guess I'm missing what you are really trying to do here...

Bill
--
William D Waddington
william.waddington@xxxxxxxxxx
"Even bugs...are unexpected signposts on
the long road of creativity..." - Ken Burtch
.



Relevant Pages

  • Re: Writing idiomatically for the cello and other string instruments
    ... writing for string instrument, specifically the cello. ... Also, get with a cello player and talk, ... Most of us sadly dont have a string player easily available- ...
    (rec.music.theory)
  • Re: Blackjack program, help needed C
    ... Since the terminating nul is important, ... if you're writing to disk. ... If the string is a complete line, ...
    (comp.programming)
  • Re: Rewrite last line in text file
    ... Now parse the buffer backwards, ... TFileStream to that point ... start writing your replacement string. ...
    (borland.public.delphi.language.objectpascal)
  • How good is PERL at searching ASCII files?
    ... some text manipulation that needs doing and I've heard many times that ... or should I just spend 3 or 4 hours writing ... segregate the three param calls from the two param calls. ... The key elements being the string CONVERT, ...
    (perl.beginners)
  • How good is PERL at searching ASCII files?
    ... some text manipulation that needs doing and I've heard many times that ... or should I just spend 3 or 4 hours writing ... segregate the three param calls from the two param calls. ... The key elements being the string CONVERT, ...
    (comp.lang.perl.misc)