How to use fscanf_P with multiline file?

Hi,
i'm using HTTPClient library (GitHub - interactive-matter/HTTPClient: An Arduino HTTP Client) for get (with HTTP GET) a text based resource.
HTTPClient return a FILE* variable as content of the page.

In my sketch i need to retrive a pattern with fscanf, but my page has X line that must be parsed. Something like this

fff: 10,
bbb: 13,
ccc: 1,
aaa: 15,
ddd: 45,

What the right code to parse multiline ("\n") with fscanf_P?

The pseudo code i think to use is this (but check only the first line):

HTTPClient client(HOST, server_ip);
FILE* result = client.getURI(PAGE_URI);
fscanf_P(result,PSTR("aaa: %i,"), &intValue);

Post the code you already have and describe what you wanna achieve.

If the problem is as you currently describe it, the answer is simple: Put a for loop around it.

Maybe you need a bit more help but then we need more information about your problem.

Sorry, i'm not described well the problem.

The loop is right answer but how to iterate?
For example

int intValue = 0;
...
while(fscanf_P(result,PSTR("aaa: %i,"), &intValue) != EOF){
Serial.println(intValue)}

doesn't work, the while return always "0" (init value of intValue var)
Is fscanf move the pointer of the file ahed (to next line) when executed?

You still haven't told us what you wanna do with your read values. Do they have to be stored in an array? Do you wanna use them directly? What are the three leading characters for? There may be better solutions than to use the fscanf function but without knowledge about your project we cannot suggest you anything.

Given your input and your code, it will never match, as "aaa:" is not at the beginning of the input stream. fscanf does not search for your string, it does try to match a given pattern, returning 0 if this wasn't possible.

I'm so sorry , the fscanf is not the solution to my problem.

I need to read the value of "aaa" from the FILE* var writed by HTTPClient library

Now, i realize that strstr() C function is my best friend so i checked the Arduino String library.
So, if the result of HTTPClient was a stirng i can do this:

String myString = "fff: 10,bbb: 13,ccc: 1,aaa: 15,ddd: 45,";
int first = myString.indexOf('aaa:');
int last = myString.indexOf(',', first);
int result = atoi(myString.substring(first,last));

So, now how can i do the same with FILE var type?

I guess fscanf isn't that bad for your problem. Try something like:

char name[5];
int value, res;
do {
  res = fscanf_P(result, PSTR("%3c: %d,"), name, value);
} while (res == 2 && strncmp(name, "aaa", 3);

The String class is a resource hog, it clobbers your memory in no time. Don't use it for projects like a web server.