How do I add char array to another array?
Code:
const void *convToChar(const char *file_path, unsigned int char_length, unsigned int line_length){
FILE *file;
char f_text[char_length + 1];
char text[char_length + 1];
file = fopen(file_path, "r");
for(unsigned int i = 0; i < line_length; i++){
fgets(f_text, char_length + 1, file);
text += f_text;
}
const char *p_text = text;
fclose(file);
printf("%s", text);
return p_text;
}
Above code is for OpenGL shader source function. The shader file needs to be converted from shader file to a char array.
This is where i'm stuck,
Code:
for(unsigned int i = 0; i < line_length; i++){
fgets(f_text, char_length + 1, file);
text += f_text;
}
text += f_text;
It says "invalid operands to binary + (have 'char[(sizetype)(char_length + 1u)]' and 'char *')"
fgets gives me the current line of the file but I need a function that stores my whole file into a big char array. Is there a function or a way to solve my problem?