• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Null-terminated data entries.

 
Ranch Hand
Posts: 531
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 531
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 531
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic