Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Null-terminated data entries.

 
Anton Golovin
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, guys!

My assignment says that if an entry in the data file is less than the maximum length specified for that entry, it is null-terminated. However, in the original data file supplied, it is not null-terminated at all! What would be advice for this matter? I am thinking about writing null-terminated strings out, but it is definitely puzzling!
 
Mike Vess
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The entries in my data file is also space filled but the assignment tells me that the entries should be null terminated. What i have done is to null-terminate the values i update/write to database but i always trim the values read from database so a null terminated value will give the same result as a space filled.
 
Anton Golovin
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mike Vess:
The entries in my data file is also space filled but the assignment tells me that the entries should be null terminated. What i have done is to null-terminate the values i update/write to database but i always trim the values read from database so a null terminated value will give the same result as a space filled.


May I ask what you put as the null-terminator? Is it a zero or a "\0"? And how do you write them, as a char turned to byte?

Thanks for your reply.
 
peter wooster
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Anton Golovin:


May I ask what you put as the null-terminator? Is it a zero or a "\0"? And how do you write them, as a char turned to byte?

Thanks for your reply.


The data in the file is bytes not chars, so the termination value is byte 0.
 
Robert Chisholm
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My data is not null terminated either, and my assignment says:


"All text values, and all fields (which are text only), contain only 8 bit characters, null terminated if less than the maximum length for the field."


It doesn't say anything about "should be".

However, that statement (IMO) implies that it can be... which is an easier process than padding out a field with blanks to make it fit the size constraints of the record.
 
Anton Golovin
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So would it be safe to ignore this? I am not sure, but it has no must, and it seems to describe existing data...
 
Robert Chisholm
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anton,

I'm doing what Mike Vess is doing (see above). It seems like the safest bet (but who knows -- it might be a candidate for choices.txt).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic