pointers - Storing a character at address location in C -
in assembly language, if have 2 variables, address a0 , byte t0, it's easy store t0 @ beginning of address a0 typing
sb $t0,0($a0)
now, want same thing in c, , in case i've got
char* a0 = "abc"; char t0 = 'w';
i know can't access , modify a0[0] directly because results in bad access error. efficient way of replacing beginning "a" in a0 value in t0?
you cannot replace 'a'
because in string literal, read-only.
you can, however, store string in array, makes letters , accessible , replace 'a'
easily:
char a0[] = "abc"; char t0 = 'w'; a0[0] = t0;
Comments
Post a Comment