I want to extract different substrings from a file with array of strings. My file resembles this.
abcdxxx
efghijkyyy
lmzzz
ncdslanclsppp
kdfmsqqq
cbskdnsrrr
From the above file I want to extract xxx, yyy, zzz, ppp, qqq, rrr (basically last 3 characters) and store into an array. I refered this link How to extract a substring from a string in C? but not felt feasible because the content in my file is dynamic and might change for next execution. Can someone give a brief on this? Here is my approach
FILE* fp1 = fopen("test.txt","r");
if(fp1 == NULL)
{
printf("Failed to open file\n");
return 1;
}
char array[100];
while(fscanf(fp1,"%[^\n]",array)!=NULL);
for(i=1;i<=6;i++)
{
array[i] += 4;
}