I create a function in C programming language for removing the start and last curly braces form json and store that data in variable but i am getting error that my function is not working correctly please can you help me
This is a potentially dangerous warning, depending on what you do.
Either create a char buffer and strcpy data into main, or use a pointer to constants:
char const * const main = data;
Also that function seems to be accepting a
char const (*), not a
char const *, but I guess that's more general.
char const *, not
char* on main, or use
char * on data, they should match, that's all.
Nuuu you do
i < strlen(main) also why are you using main as a variable name and also the original for loop was fine, the only problem is that it’s actually a pointer to constant memory, so the characters aren’t going to change. You need to use strcpy or memcpy in order to make a new, mutable string.
@Coder100 No, you cannot safely ignore every warning. Definitely not in C or C++. It might look like nonsense and maybe still compile fine but usually if you're getting a warning you are doing something wrong.
That something can possibly just be redundant logic, or it could be a mistake with something such as pointer arithmetic, which in that case can cause your program to A. Segmentation Fault, B. Work fine in some cases but randomly segfault in others or C. Doesn't segfault, but does nothing or something very different from what you wanted it to do. There's a reason you see OS Development tutorials turning on every single warning.