int main()
{
char content[255];
char strings[3][255];
FILE *file = fopen("test.txt", "r");
if (file == NULL)
{
printf("Couldnt open the file");
}
int counter = 0;
while (!feof(file))
{
fgets(content, 15, file);
printf("%s", content);
strncpy(strings[counter], content, sizeof(content));
counter++;
}
for (int i = 0; i < 3; i++)
{
printf("%s\n", strings[i]);
}
}
I basically just want to read from a file lines of string and cope them into an array of strings.
When i print them something weird happens
The first line printed is separated by a newline
the last one is cut off