R
rahul8143
hello,
what is difference between sizeof("abcd") and strlen("abcd")? why
both functions gives different output when applied to same string
"abcd".
I tried following example for that.
#include <stdio.h>
#include <string.h>
void main()
{
char *str1="abcd";
char str2[]="abcd";
printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd"));
printf("%d %d %d",strlen(str1),strlen(str2),strlen("abcd"));
}
what is difference between sizeof("abcd") and strlen("abcd")? why
both functions gives different output when applied to same string
"abcd".
I tried following example for that.
#include <stdio.h>
#include <string.h>
void main()
{
char *str1="abcd";
char str2[]="abcd";
printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd"));
printf("%d %d %d",strlen(str1),strlen(str2),strlen("abcd"));
}