I'm trying to cut the first 4 chars (PWD=) of the environment variable, my_envp[0], which in this instance is "PWD=/home/usrnm/cprgms/project"
This is my attempt:
Code:
char pwd[] = "PWD=";
printf("my_envp is: %s\n", my_envp[0]);
memset(my_envp[0], '\0', strspn(pwd, my_envp[0]));
printf("my_envp is now: %s\n", my_envp[0]);
The second printf does not print anything. If I replace '\0' with a different character like 'k' it prints "kkkk/home/usrnm/cprgms/project"
My questions are: What am I doing wrong? and why doesn't my implementation work logically?
Thanks in advance for any help.