Convert int to string / char Arrays

Hi there!
I am using virtual wire + ATtiny 85 to send data over an RF Link that then gets received by an Arduino UNO.
If I use the standard example everythink works fine, and it sends every string I want.

But now I want to be able to send changing string and Numbers (int?); e.g. sensor data, counters, ...
I do program (mostly java atm) and I learned C++ some years ago but here I get confused...

They convert a String into an array of chars and send them. I tried to dublicate that by creating my own array and trying things like

char *myarray;
myarray[0] = i; // i = counter

but nothing reaches the receiver.
How do I send numbers and changing stuff?

// transmitter.pde
//
// Simple example of how to use VirtualWire to transmit messages
// Implements a simplex (one-way) transmitter with an TX-C1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@open.com.au)
// Copyright (C) 2008 Mike McCauley
// $Id: transmitter.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $

#include <VirtualWire.h>

void setup()
{
    // Initialise the IO and ISR
    vw_set_tx_pin(3);
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000);	 // Bits per sec
}

void loop()
{
    const char *msg = "hello";

    vw_send((uint8_t *)msg, strlen(msg));
    vw_wait_tx(); // Wait until the whole message is gone
    
    delay(200);
}

Not sure if sprintf works on a tiny85

Thanks, I will try that but the strange thing is, that it seems to not be working at all with strings.

If I try that:

String test = "hello";
    const char *msg = test;

I get a: "error: cannot convert 'String' to 'const char*' in initialization"

char *myarray;
myarray[0] = i; // i = counter

Declare a pointer, don't point it to anything, and try to put data in it.

How do I send numbers and changing stuff?

itoa() would be a good start

LastSamurai:
Thanks, I will try that but the strange thing is, that it seems to not be working at all with strings.

If I try that:

String test = "hello";

const char *msg = test;




I get a: "error: cannot convert 'String' to 'const char*' in initialization"

Why bother with String objects? Seems like a terrible idea to use them on a Tiny85

char *myarray;
myarray[0] = i; // i = counter

myarray is a pointer. It is NOT an array, in spite of the name. You can not treat it as an array unless you point it to an array.

Storing an int in a char is not the way to make a string of the int.

If sprintf() doesn't work, itoa() might.

I agree with Arrch...get rid of the String objects. Instead of:

String test = "hello";
const char *msg = test;

can't you use:

char test[] = "hello";
const char *msg = test;

instead? Always remember that a pointer can only hold two things: null ('\0'), which means it's not a valid pointer, or a memory address (the lvalue of a data item).