-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create string type #22
Comments
struct string_t {
char *str;
size_t len;
size_t capacity;
}; |
One advantage is that the type could be mutable: it dynamically changes its size on demand. We could also make an immutable string. That has its uses as well. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The default char * array in C works fine, but its prone to errors. Since it does not keep track of the length of the string, buffer overflows and other security vulnerabilities are common. Modern computers have enough memory to store the length of the char * with the string. This would make it easier, and more safe, to use. If we were to implement a string type we would make sure it can be compatible with all the builtin str functions. We could also just make some of our owns.
The text was updated successfully, but these errors were encountered: