Adding a value to my array/string

Hi guys, noob programmer looking for advice please!!

I have set up two arduinos talking to each other with RF transmitters, using the virtualwire library. I convert my desire int to a character string using itoa() and then bounce it across using the library calls...happy days.

I now want to add a value to the string created by the itoa() function, totally independant of the original integer, so i thought that this would work

 char tempString[9];
  itoa(temp, tempString, 10);

// switch monitoring

  tempString[3] = 'A';
  Serial.println ("Switch A on");
  Serial.println (tempString[3];

I intend to pick out the character from the string on the other arduino and use it with an "if" function to give indication of the switch. My problem is that when i print to serial the tempString[3] value, it gives no return (or at least nothing is printed).

I have tried

tempString[3] = A


tempString[3] = ((char A));

but I am resorting to guesswork now, which does not provide much productivity!

Please excuse any non-standard terms or foolish errors,as I am a high voltage electrician by trade and do not often deal with anything less than 11kV!

You're missing a ) on your print, so that code cannot even compile.

Apologies, I amended that in the browser as I didn't copy enough relevant parts of my code...

Any ideas on the issue?

You could post all your code, as it compiles right now.

It has got a bit messy as I have been faffing about with it but here is what I’m working with at the moment…

#include <VirtualWire.h>
  int temp = 123;
void setup()
   Serial.begin(9600);	  // Debugging only
   Serial.println("setup complete");
   pinMode(4, INPUT);
   digitalWrite(4, HIGH);
  //Setup RF Transmitter
  // Initialise the IO and ISR
    vw_setup(2000);	 // Bits per sec
    vw_set_tx_pin(3); //Transmit Pin = 3


void loop() {
//convert the temp reading to a transmittable sting	

  char tempString[4];
  itoa(temp, tempString, 10);


// monitoring

  tempString[3]= 1;
  Serial.println ("on");
  Serial.print (tempString);
  Serial.println ("off");
  Serial.print (tempString);
//transmit string
  digitalWrite(13, true); // Transmitting light
  vw_send((uint8_t *)tempString, strlen(tempString));
  digitalWrite(13, false);


You're overwriting the string terminator. If you overwrite with zero, no big deal, but any non zero value is going to screw strlen.

That code looks nothing like what you posted first - please remember to post what you're using, otherwise it just wastes time.

Thanks, a stupid mistake I should've known and I spotted it just before your reply. I had a bigger string before but still no joy, must've been another problem which I have solved along the way. With a larger string I have a working system. Thanks for responding nice and fast and helping out!