string with 3 numbers

In arduino (Mega 2560) I have code which sent a string to Processing,
The string looks like "201 , 225 , 10" and processing receives the same string.
In processing I want the 3 values in this string for fill(201 , 225 , 10)
how to extract these 3 values from the string?

Show us the code that loads the "string" with data and someone will surely help. Incidentally, the last character is a line feed, which you probably want to discard.

iint
getArgs (
    char *s,
    int  *arg,
    int   nArg )
{
    int i;
    strtok (s, "(");
    for (i = 0; i < nArg; i++)
        if (0 == (arg [i] = atoi (strtok (NULL, ","))))
            break;
    return i;
}

// -----------------------------------------------------------------------------
void setup()
{
    Serial.begin (9600);

    int  arg [5];
    char s [] = "fill(201 , 225 , 10)";
    int  n    = getArgs (s, arg, 5);

    for (int i = 0; i < n; i++)
        Serial.println (arg [i]);
    Serial.println ();
}

void loop()
{
}

Or you can combine the following functions:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.