What is the problem with this code? It works.
What is the problem with this code? It works
Why are you hiding the fact that it's a pointer?
Because what's the point?
Not only is it unnecessary confusion, it's longer to type too
using std string;
not in c
typedef char* c*;
It's extremely misleading.
You're abstracting the pointer declaration, you're re-naming it to an STL class with the same function.
It's highly misleading
What's a char[] then?
It's not a string. It's just a series of bytes.
Cturds can't unicode.
Memory isn't allocated with this.
typedef struct {
size_t len;
unsigned wlen;
void *data;
} _Cstring_t;
An array of chars
Use strings dude
It's not 1986 anymore
>len
>Cstring
No.
>enjoy your segfault
someone else could use the same name for wchar_t*
then you would need to create an entire library of functions just to use the type
every standard library function would then need to be wrapped in a new function to use your shitty string idea
You should use char*, because pointer arithmetic like data[3] on void* is undefined behavior.
Who are you quoting?
who are you quoting?!
That's little effort and not even hard.
But for C this is what strings are...
For C++ definitely use the standard string class
>dereferencing void *
Enjoy your UB, faggot.
You can cast void* to LITERALLY anything you want you stupid nigger.
If you just have a void pointer inside a struct though, like in the example, you can't simply dereference it.
>you can't simply dereference it.
(char*)(pointer_to_void)
stupid nigger
why not declare it as a char pointer then?
It's more generic that way.