Getting value from char array

Hi

I solve my problem with receiving datas from one arduino to other arduino, but now i need to get values from char array, I developed this code in C++, but non works correctly in Arduino IDE

#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <cmath>
using namespace std;

char receive[30] = "25545*5455*59*754";
int number[4] = {0,0,0,0};
int main()	{
	int a = 3, temp = 0;

	for(int i = (unsigned)strlen(receive)-1; i >= 0;i--)	{
		if(receive[i] != '*') {
			number[a] += ((int)receive[i]-48)*pow(10,temp);
			temp++;
		}
		else {
			a--;
			temp = 0;
		}
		
	}
	for(int i = 0; i < 4; i++)
		cout << number[i] << endl;
	return 0;
}

here is code for receiving values from one arduino to other arduino

int number[4] = {0,0,0,0};
const byte numChars = 40;
char receivedChars[numChars];

boolean newData = false;

void setup() {
    Serial.begin(9600);
    Serial.println("<Arduino is ready>");
}

void loop() {
    recvWithStartEndMarkers();
    showNewData();
   int i=0;

  if (Serial.available()) {
    delay(100); 
    while(Serial.available() && i<4) {
      receivedChars[i++] = Serial.read();
    }
    receivedChars[i++]='\0';
  }
  /*int a = 3, temp = 0;
  for(int i = (unsigned)strlen(receivedChars)-1; i >= 0;i--)    {
        if(receivedChars[i] != '*') {
            number[a] += ((int)receivedChars[i]-48)*pow(10,temp);
            temp++;
        }
        else {
            a--;
            temp = 0;
        }
       
    }
    for(int m = 0; i < 4; m++)
        Serial.println(number[m]);*/
}

void recvWithStartEndMarkers() {
    static boolean recvInProgress = false;
    static byte ndx = 0;
    char startMarker = '<';
    char endMarker = '>';
    char rc;
 
    while (Serial.available() > 0 && newData == false) {
        rc = Serial.read();

        if (recvInProgress == true) {
            if (rc != endMarker) {
                receivedChars[ndx] = rc;
                ndx++;
                if (ndx >= numChars) {
                    ndx = numChars - 1;
                }
            }
            else {
                receivedChars[ndx] = '\0'; 
                recvInProgress = false;
                ndx = 0;
                newData = true;
            }
        }
        else if (rc == startMarker) {
            recvInProgress = true;
        }
    }
    
}

void showNewData() {
    if (newData == true) {
        Serial.print("This just in ... ");
        Serial.println(receivedChars);
        newData = false;
    }
}

Thanks for help

marcopinter999:
I developed this code in C++, but non works correctly in Arduino IDE

Two things:

  1. Arduino is C++ as well, no problem there. But not all libraries are available and doing heavy math is off the table.
  2. "but non works correctly" is like "does not work" NEVER a explanation of what doesn't work. What does happen? What do you expect? Why?

but non works correctly in Arduino IDE

Code doesn't "work" in the IDE. It just sits there, sometimes looking good and sometimes looking stupid.

Your code, if it compiles, does something when run on the Arduino. "but non works" is too lame to even consider. What DOES the code do? What do you expect it to do?

WHY do you have a main() function that does not call init()?