I am trying to read a file into a string all at once, however I have only been able to read it in line by line with this code:
int main()
{
char input[1000000];
FILE *fPointer;
fPointer = fopen("/Users/boys/users.json", "r");
if( fPointer != NULL)
{
while(!feof(fPointer))
{
fgets(input, 1000000, fPointer);
//printf("%s", input);
}
}
printf("%s", input);
return 0;
}
I am dealing with a json file and have only used csv and simpler files in the past with c as I am still quite new to it and not all that good so if anyone has a simple solution to reading a file in all at once rather than line by line that would be a great help, thanks!