I have read on Wikipedia that the Cyclone programming language is a safe dialect of the C programming language so consider the following C code.
int strlen(const char *s)
{
int iter = 0;
if (s == NULL) return 0;
while (s[iter] != '\0') {
iter++;
}
return iter;
}
This function assumes that the string being passed in is terminated by NUL ('\0'). But if we pass a string like this,
char buf[] = {'h','e','l','l','o','!'}
it would cause strlen
to iterate through memory not necessarily associated with the string s. So there is another version of this code in Cyclone
int strlen(const char ? s)
{
int iter, n = s.size;
if (s == NULL) return 0;
for (iter = 0; iter < n; iter++, s++) {
if (*s == '\0') return iter;
}
return n;
}
Can I use Cyclone in Visual Studio or do I have to donwload a new compiler?