Created
January 29, 2015 16:32
-
-
Save ninjatrench/ee3643a53db4fb7ce7d1 to your computer and use it in GitHub Desktop.
strlen vs sizeof
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<string.h> | |
void main(){ | |
const char str[] = "Heya Buddy"; | |
printf("sizeof(%s): %zu\n", str ,sizeof(str)); | |
printf("strlen(%s): %zu\n", str, strlen(str)); | |
const char* str2 = "Heya Buddy"; | |
printf("\n"); | |
printf("sizeof(%s): %zu\n", str2, sizeof(str2)); | |
printf("strlen(%s): %zu\n", str2, strlen(str2)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment