There is a char data type which contains the following text:
+CMT: "+79643437397","","15/06/09,17:34:01+12" 1+ON+60 It starts with \ r \ n , but here it does not display, because in the buffer from where it turns out there may be other data, it is required to split it by \ r \ n and check the length, if the length is 3 lines, then the last line is necessary split by plus, on JS I would do it like this:
var a = " +CMT: "+79643437397","","15/06/09,17:34:01+12" 1+ON+60 "; var b = a.split("/r/n"); if (b.length == 3) { var c = b[2].split("+"); if (c.length == 3) { // Выполнение функции по полученным данным из c ({1, "ON", 60}) } } But I work with C for the first time, I decided to run an example that I found on the Internet:
#include <stdio.h> #include <string.h> #include <malloc.h> char str[] = "John|Doe|Melbourne|6270|AU"; char *fname, *lname; char *oldstr = malloc(sizeof(str)); strcpy(oldstr,str); fname=strtok(str,"|"); lname=strtok(NULL,"|"); printf("Firstname: %s\n", fname); printf("Lastname: %s\n", lname); free(oldstr); but everything is so smooth here, the malloc.h library was not in the Arduino development environment at all, I downloaded this - http://gee.cs.oswego.edu/pub/misc/malloc.h , but I think it’s obviously that This is not the case; as a result, the error
Blink.ino: In function 'void setup()': Blink:27: error: invalid conversion from 'void*' to 'char*' [-fpermissive] invalid conversion from 'void*' to 'char*' [-fpermissive] Here's what is on line 27:
char *oldstr = malloc(sizeof(str)); As a result, I don’t know what to do with all this, help with an example.
char *oldstr = (char *)malloc(sizeof(str));- user6550void *tochar *) in Arduino to C is not. - AnT