I am trying to make a translator. This is the part where I put all the strings from the text file on the memory. But the program ignores the first string of the text file.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct b
{
char b[30];
}b;
int main()
{
int d,c,i=0;
char k[30],x;
b *a;
FILE *fp;
if ((fp=fopen("translate.txt","r"))==NULL)
{
printf("Σφάλμα κατά το άνοιγμα του αρχείου\n");
}
else
{
while(!feof(fp))
{
fscanf(fp,"%s",k);
i++;
}
a=malloc((i)*(sizeof(b)));
fclose(fp);
}
if ((fp=fopen("translate.txt","r+"))==NULL)
{
printf("Σφάλμα κατά το άνοιγμα του αρχείου\n");
}
else
{
rewind(fp);
for (c=0;c<i;c++)
{
fscanf(fp,"%s",a[c].b);
}
fclose(fp);
}