Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Memory/heap corruption during string manipulation
Okay, having said all that I think I might be able to show something weird happening with that capitalisation line of code in a simpler program.

This code repeatedly sets a string to 'test' and then tries to capitalise the first letter to give 'Test':

#include <alloc.bas>
dim st$ as string


sub printmem()
    dim f, m as uinteger
    f = memavail
    m = maxavail
    print at 22,0; ink 6; paper 2; flash 1;str$(f);" ";at 22,15;str$(m);" "
    do while inkey$<>""
    do while inkey$=""
end sub

sub capstring()
    print at 0,0;st$
    IF  CODE (st$(1))>96 THEN LET st$(1)=CHR$ ( CODE (st$(1))-32): END IF
    print at 1,0;st$
end sub

sub start()
end sub

The weird thing here is the longer you run the routine, the higher the value of memavail - it just gets bigger and bigger. Would I be correct in assuming it's not supposed to behave like that?

Messages In This Thread

Forum Jump:

Users browsing this thread: 1 Guest(s)