Ethernet Shield - Charactere per charactere to string

Hi everybody,

i have try this code for get a value in a online text file but the code display the value charactere by character and display the http requests before.

Can you help me for don’t display the http requests and get the value in a string ?

Thank a lot and bests regards

The code :

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char serverName[] = "www.la-referencerie.fr";
EthernetClient client;

void setup(){

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    while(true);
  }

  Serial.begin(9600);
}

void loop(){
      
      if (client.connect(serverName, 80)) {
        client.println("GET /unnicoin/unnicoin.txt HTTP/1.0");
        client.println("Host: www.la-referencerie.fr");
        client.println();
      } 
      else {
        Serial.println("connection failed");
        Serial.println();
      }
    
      while(client.connected() && !client.available()) delay(1); 
      while (client.connected() || client.available()){
        char data = client.read();
        Serial.print(data);

        
      }
      client.stop();
      
}

in this prototype I am receiving a line of data in response to a HTTP GET request

   while(client.connected())
  {
    while(client.available())
    {
      inChar = client.read();
      Serial.write(inChar);
      // if end of line reset to start elese copy character to data[]
      if(inChar < ' ') index=0; else data[index++]=inChar;
      if(index>99)index=99; // in case of data overrun
      data[index]=0;
      // set connectLoop to zero if a packet arrives
      connectLoop = 0;
    }

once I have the characters in data I use the string tokeniser strtok() to extract integer numbers

what is the code you have use ?

Can you help me for extract only the value of the online text file ?

Thanks and bests regards

what is the code you have use ?

You have to have an array to store the data in. You have to have some variable that keeps track of where to write into the array.

It should be obvious what part of the code that horace posted does that.