user1499: I have this code:
#include <TinyGPS++.h>
#include <SoftwareSerial.h>


#define GPS_RX_PIN 2
#define GPS_TX_PIN 3

TinyGPSPlus gps;
SoftwareSerial ss(GPS_RX_PIN, GPS_TX_PIN);

void setup()
{
  Serial.begin(9600);
  ss.begin(4800); 
}

char clat[11];
char clng[11];

void loop()
{

        bool isGpsLocationValid = false;
        do
        {  
            while (ss.available()>0)
            {
                char c = byte(ss.read());
                if (gps.encode(c)) 
                {    
                    if (gps.location.isValid())
                    {
                        dtostrf(gps.location.lat(), 11, 6, clat);
                        dtostrf(gps.location.lng(), 11, 6, clng);
                        isGpsLocationValid = true;
                    }
                }   
             }
        } while (isGpsLocationValid == false);
        Serial.write(clat);
        Serial.println();
        Serial.write(clng);
}

Now when all is done, the clng value is printed twice in the serial monitor.
The value i get is in this format:
27.275869  15.151013
  15.151013

As you can see, clng is printed twice. Any ideas why is that?

user337: The width parameter to dtostrf() is the width of the resulting string NOT including the null terminator. So you are overflowing the array.
Change:
char clat[11];
char clng[11];

to
char clat[12];
char clng[12];

and it should work.

1499: <p>I have this code:</p>

<pre><code>#include &lt;TinyGPS++.h&gt;
#include &lt;SoftwareSerial.h&gt;


#define GPS_RX_PIN 2
#define GPS_TX_PIN 3

TinyGPSPlus gps;
SoftwareSerial ss(GPS_RX_PIN, GPS_TX_PIN);

void setup()
{
  Serial.begin(9600);
  ss.begin(4800); 
}

char clat[11];
char clng[11];

void loop()
{

        bool isGpsLocationValid = false;
        do
        {  
            while (ss.available()&gt;0)
            {
                char c = byte(ss.read());
                if (gps.encode(c)) 
                {    
                    if (gps.location.isValid())
                    {
                        dtostrf(gps.location.lat(), 11, 6, clat);
                        dtostrf(gps.location.lng(), 11, 6, clng);
                        isGpsLocationValid = true;
                    }
                }   
             }
        } while (isGpsLocationValid == false);
        Serial.write(clat);
        Serial.println();
        Serial.write(clng);
}
</code></pre>

<p>Now when all is done, the clng value is printed twice in the serial monitor.
The value i get is in this format:</p>

<pre><code>27.275869  15.151013
  15.151013
</code></pre>

<p>As you can see, clng is printed twice. Any ideas why is that?</p>
 337: <p>The width parameter to <code>dtostrf()</code> is the width of the resulting string NOT including the null terminator. So you are overflowing the array.</p>

<p>Change:</p>

<pre><code>char clat[11];
char clng[11];
</code></pre>

<p>to</p>

<pre><code>char clat[12];
char clng[12];
</code></pre>

<p>and it should work.</p>
