Reputation: 363
I try to understand why my simple code who use bzero
or memset
cause a bus error
with clang
or gcc
I find no logical explication.
I try the simple example from this post : Proper way to empty a C-String
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
char *str;
printf("%lu\n",strlen(str));
bzero(str,1); // ok
str = "bonjour";
bzero(str,strlen(str)); // bus error
// memset(str, 0, strlen(str)); // bus error
return(0);
}
Upvotes: 0
Views: 241