0

I'm reading a string from a buffer, and at some point I need to stop and get the string of what I've read so far and get the size of this string, so let's say I've the string: "StackOverflow" and going to use "v" as my stop point, so I should have something like "StackO" as my result string.

The thing is, to count the size of it, I'm reading byte by byte, so when I get to the stop point, the register $t0 which is counting the size of it should have the value 6 in it. So, how can I create a string that has "Stack0" in it?

1 Answer 1

1

Assuming you are using null-terminated strings, you can either a) copy the string to another buffer and add a 0 (null character) after the 6th character, or b) put the 0 in the original buffer after the 6th character, overwriting the ‘v’, if you don’t mind destroying the original string.

Sign up to request clarification or add additional context in comments.

3 Comments

How would I put the 0 after the 6th character?
@PauloCalado: sb $0, ($t1), where $t1 is the pointer to the 'v' you already have (because you had to load it in the first place).
Thank you very much sir!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.