Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //fixed issue with extra chars and new lines.
- char* GetValueOfKeyArray(char* _array, char* keyname)
- {
- char *output = (char*)malloc(0);
- for (size_t i = 0; i < strlen(_array); i++)
- {
- if (_array[i] == keyname[0])
- {
- char* t_array = (char*)malloc(strlen(keyname) + 1);
- memcpy(t_array, _array + i, strlen(keyname));
- t_array[strlen(keyname)] = '\0';
- if (strcmp(t_array, keyname) == 0)
- {
- int size = 0;
- char* t_output = (char*)malloc(strlen(_array) - strlen(t_array) - i + 1);//(char*)realloc(output, strlen(_array) - strlen(t_array) - i + 1);
- memcpy(t_output, _array + strlen(t_array) + i + 1, strlen(_array) - strlen(t_array) - i + 1);
- for (size_t i = 0; i < strlen(t_output); i++)
- {
- size = i;
- output = (char*)realloc(output, i);
- if (t_output[i] == '\n')
- break;
- }
- memcpy(output, t_output, size);
- output[size] = '\0';
- return output;
- }
- }
- }
- return "failed you dipshit";
- }
Advertisement
Add Comment
Please, Sign In to add comment