I want to write a program that determine the string length
But i have no idea how
Can anyone help me??
Four answers:
DogmaBites
2010-10-28 17:33:26 UTC
You count the characters from the beginning of the string until you hit the terminating NUL (0). Remember that the NUL might be the very first character, which means the length is zero.
Din
2010-10-28 17:35:53 UTC
It depends on how the string is terminated. Most of the time I terminate my own data strings with a NULL byte (binary 0), like so:
TestString db "Now is the time for all good golfers to come to the aid of their country club.",0
Everything in quotes is the string. The 0 at the end is the terminator. This is also the way C and C++ terminate strings. If that's what you're working with than all you've got to do is start a count at the first byte and compare each character byte to 0. If it's equal to 0 you've reached the end of the string. If not increment the count, move to the next byte, and repeat the test.
On the other hand, sometimes your string may be terminated with another character. DOS interrupt 21h function 9h does this to print an entire string continuously until it runs into a "$" character (as opposed to interrupt 21h function 2h which simply prints one character at a time; you have to step through the string manually to print all of it). If so they simply compare each byte to "$" instead of NULL. This is far less likely than NULL termination, though.
?
2010-10-28 17:33:59 UTC
My assembly experience as been with micro controllers. As such I can tell you that I have defined strings in memory much like a string is defined in C as a character array that is accessed using a pointer. You use a pointer to the memory location where the string starts and then increment through the memory reading each character value until you find a null, zero value (\0 in C).
So to determine the lenght start at the begining of the string and increment through the memory counting each location examined until you find a memory location that is 0x00 (null). The count is the lenght.
?
2016-12-03 07:09:28 UTC
whats up, seems such as you have tried approximately each little thing. Lighter strings ought to help. relies upon on how close to to being in music that's on the twelfth. Thicker strings prefer extra length for intonation. dropping right down to 9-42s ought to get you there while you're already close. If no longer, you should shim the neck. circulate it slightly far flung from the physique. that gets you an prolonged string length. frequently which potential plugging the mounting holes on the heel of the neck. Drillng new ones. Then upload a small shim between the heel of the neck and the tip of the neck pocket. i do no longer see how new saddles will help. you prefer extra length and you're out of room on the bridge. If thinner strings would not get it intonated, you will ought to circulate the neck. Later, whats up, Dana makes a reliable factor. I forgot that step. till now you progression the neck do attempt a shim below the top element to the neck. it incredibly is a miles less intrusive fix if it works. would not consistently artwork, yet I consistently attempt that till now I hotel to moving the neck. I shrink a %. of a nail sanding persist with in superb condition between the top 2 screw holes. The sand paper end helps is stay in place as I placed the neck back on. Lay the shrink strip of the nail sanding strip so it runs between the top screw holes. which will replace the lean of the neck. it ought to grant you with adequate to set the intonation. If no longer, take it out and circulate the neck.
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.