Hi,
- Question
Why does valgrind complain?Conditional jump or move depends on uninitialised value(s) ==25636== at 0x4C26D29: strlen (mc_replace_strmem.c:242) ==25636== by 0x40060A: main (test.c:7)
- Question
Strlen doesnt apparantly tell you how much space you have in your array, but the number of chars til '\0'.
I my case i've alloced space for 80 chars,
so when I'm strduping, will my new array also hold 80 or just till the strlen of the old char array?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
char* str1 =(char *) malloc(80*sizeof(char));
printf("length of str1:%d\n",(int)strlen(str1));
str1 = "test_of_string\n";
printf("length of str1:%d\n",(int)strlen(str1));
char* str2 = strdup(str1);
printf("length of str1:%d\n",(int)strlen(str2));
return 0;
}
thanks