COMP1927 FAQ

Assignment 1

How does the newTB work?

It the input text is, for example "Hi\nhow\nare\nthings\n\0" the buffer should contain the following lines:
"Hi"  
"how" 
"are" 
"things"	
So you will have to process the input string, extract all the substrings separated by newline, and copy them into the entries of your buffer structure.

Can TB be defined like link in the lecture examples?

If TB points directly to the head of the list, it will not work with the interface, since functions like merge may have to change the first entry in the buffer tb1, but would not be able to do this if tb1 points directly for the first entry.

Can we assume that every line in the input string for newTB is terminated by \n

Yes - you can assume that in all our testcases for automarking, the input string for newTB will end with \n\0.

Can we assume that str1 and str2 will be the same size in replaceText?

No you might be replacing one string with a longer string and your original chunk of memory may not be big enough. You will need to solve this problem.

if the input into "replaceTB" is searching for an empty "" string, what happens?

Nothing is done in this situation. Nothing should be replaced.

What should happen if we run mergeTB (tb1, 1, tb1)

Nothing should happen. tb1 should remain unchanged. Attempts to merge a textbuffer with itself should just be ignored.