Jump to content

String Character Length: Difference between revisions

→‎[[C]]: another way
(Added a couple other sml compilers, will make pages for them)
(→‎[[C]]: another way)
Line 10:
 
#include <string.h>
 
int main(int argc, char ** argv) {
const char *string = "Hello, world!";
size_t length = strlen(string);
return 0;
};
 
or
 
int main(int argc, char ** argv) {
const char *string = "Hello, world!";
int length;
for(length=0; string[length]!='\0'; length++); // for each letter that is not a '\0' adds
// one to length's value.
// '\0' is the string terminator character.
return 0;
};
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.