Allocate memory and save string in c

char *test = (char*) malloc(12*sizeof(char)); +-+-+-+-+-+-+-+-+-+-+-+-+ test—>|x|x|x|x|x|x|x|x|x|x|x|x| (uninitialized memory, heap) +-+-+-+-+-+-+-+-+-+-+-+-+ test = “testingonly”; +-+-+-+-+-+-+-+-+-+-+-+-+ test + |x|x|x|x|x|x|x|x|x|x|x|x| | +-+-+-+-+-+-+-+-+-+-+-+-+ | +-+-+-+-+-+-+-+-+-+-+-+-+ +->|t|e|s|t|i|n|g|o|n|l|y|0| +-+-+-+-+-+-+-+-+-+-+-+-+ free(test); // error, because test is no longer pointing to allocated space. Instead of changing the pointer test, you need to copy the string “testingonly” into the allocated place using e.g. … Read more

How Can I inherit the string class?

Another option could be to use an implicit operator. Example: class Foo { readonly string _value; public Foo(string value) { this._value = value; } public static implicit operator string(Foo d) { return d._value; } public static implicit operator Foo(string d) { return new Foo(d); } } The Foo class acts like a string. class Example … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)