I want to save the contents of a .txt file into an array. The thing here is I am using the location first into another array and I want to use that array holding my location to store the contents of the file into an array. The code doesn't seem to work. Help appreciated.
#include <stdio.h>
#include <string.h>
int main()
{
char location[50],input[1000]={0};
int i=0;
printf("Enter your file location:\n");
scanf("%999[^\n]",location);
FILE *ptr;
ptr = fopen("location", "r");
while(!EOF)
{
char c;
c = (char) fgetc(ptr);
input[i] = c;
printf("%c", input[i]);
i++;
}
input[i] = NULL;
printf("%s",input);
getch();
return 0;
}