#include <stdio.h> int get_length(char *cstring) { int length = 0; while (cstring[length] != '\0') { length++; } return length; } int main(void) { char *text[] = { "Steffan", "Pascal", "Jade" }; printf("%s is %d chars.\n", text[0], get_length(text[0])); printf("%s is %d chars.\n", text[1], get_length(text[1])); printf("%s is %d chars.\n", text[2], get_length(text[2])); // Do not change the following code char user_input[64]; scanf("%63[^\n]", user_input); printf("%s is %d chars.\n", user_input, get_length(user_input)); return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter