int main(){
char* str = "bake", *temp = str;
char alpha [] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
for (int i = 0 ; temp[i] != '\0'; i++) {
for (int j = 0; alpha[j] != '\0'; j++) {
temp[i] = alpha[j];
printf("%s\n",temp);
}
temp = str;
}
return 0;
}
Why am I trying to replace a character in a particular location it falls to me? i want it print me like that
i = 0 (index 0 he change only the first char).
aake
bake
cake
dake
....
i = 1(index 1 he change only the second char).
bake
bbke
bcke
bdke
....
i don't understand why temp[i] = alpha[j]
not work... what i need to do that i can change the char.
thank you a lot for helps
![enter image description here][1] [1]: https://i.sstatic.net/v0onF.jpg
char *str = "bake";should bechar str[] = "bake";*temp = strlooks really weird, and doesn't jive with howtempis used later. Did you mean to usechar *temp = strdup(str);?alpha[j] != '\0'",'\0'isn't anywhere inalpha