L-sytem example

Hi! im looking for a Lsystem tutorial or example! any help would be appreciate!
Thanks!

looks like there is some example code here: L-System

1 Like

awesome! this look great.
But im trying to compile and i get this

try const int length = or
string substr[curString.length()];
you need a const there…

hey! stil having that…

string is not a plain old data (POD) type and can’t be allocated on the stack like a c-style array because it can vary in length.

If you want to use an array like this, you can allocate on the heap like this:

    std::string* substr = new std::string[curString.length()];

just make sure you eventually call

delete[] substr;

at some point after you are finished with it.

Also, it may be better to use a std::vector<std::string> and preallocate curString.length() then you won’t have to worry about cleaning up with the call to delete[].

Hey! thanks a lot! is running using this std::string* substr = new std::string[curString.length()];
but is crashing at some point.
can you show me how to write the second option please?
i havent clear how to do it.

id you call delete[] at the end of the function? If you don’t, your program will crash.