user71889: I'm trying to use this code to get temperature and humidity values from DHT11 sensor and send it to Python and I need to write the temperature and humidity values in the same line. But I keep getting the error code

expected primary-expression before '%' token

How can I fix this?
#include <dht.h>
#include <stdio.h>
int a = 0;
int b = 0;
char buffer [64];

dht DHT;

#define DHT11_PIN 7

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

void loop(){
  a = DHT.temperature;
  b = DHT.humidity;
  int chk = DHT.read11(DHT11_PIN);
  sprintf(buffer, %d %d, a, b);
  Serial.print(buffer);
  delay(1000);
}


user58653: You are missing quotes on the second parameter of sprintf:
sprintf(buffer, "%d %d", a, b);


71889: <p>I'm trying to use this code to get temperature and humidity values from DHT11 sensor and send it to Python and I need to write the temperature and humidity values in the same line. But I keep getting the error code</p>
<blockquote>
<p>expected primary-expression before '%' token</p>
</blockquote>
<p>How can I fix this?</p>
<pre><code>#include &lt;dht.h&gt;
#include &lt;stdio.h&gt;
int a = 0;
int b = 0;
char buffer [64];

dht DHT;

#define DHT11_PIN 7

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

void loop(){
  a = DHT.temperature;
  b = DHT.humidity;
  int chk = DHT.read11(DHT11_PIN);
  sprintf(buffer, %d %d, a, b);
  Serial.print(buffer);
  delay(1000);
}
</code></pre>
 58653: <p>You are missing quotes on the second parameter of <code>sprintf</code>:</p>
<pre><code>sprintf(buffer, &quot;%d %d&quot;, a, b);
</code></pre>
