Delete string in char*

Hi guys, I am having some problems. I have this char* : "this is bob.[aaa]", what I need is deleting everything after the first "[".
So it will be: "this is bob.".
I tried searching on google but I just found about std::string.. Thanks in advance for your help :)

char* str_var = (char*)(*(DWORD*)0x123456 + 0x00);

That's how I am getting the char*.
Last edited on
If it's a normal C string (terminated by a null character), then you can just write a null character after the first '[' You can use strchr() to find the '['

1
2
char *cp = strchr(str_val, '[');
if (cp) cp[1] = 0;

Thanks :D
Topic archived. No new replies allowed.