Skip to main content
added 198 characters in body
Source Link

You could try to use strtok. Code from my mind and not tested:

#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
    char string[] = "2"AT+CMGL=\"ALL\"\n"
    "\n"
    "+CMGL: 2,\"REC READ\",\"+639321576684\",\"Ralph Manzano\",\"16/04/25,21:51:33+32\"";33+32\"\n"
    "Yow!!!\n"
    "\n"
    "OK\n";
    char delimiter[] = ",";\n";

    // initialize first part (string, delimiter)
    char* ptr = strtok(string, delimiter);

    while(ptr != NULL) {
        printf("found one part: %s\n", ptr);
        // create next part
        ptr = strtok(NULL, delimiter);
    }

    return 1;
}

Outputs:

found one part: AT+CMGL="ALL"
found one part: +CMGL: 2
found one part: "REC READ"
found one part: "+639321576684"
found one part: "Ralph Manzano"
found one part: "16/04/25
found one part: 21:51:33+32"
found one part: Yow!!!
found one part: OK

You could try to use strtok. Code from my mind and not tested:

#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
    char string[] = "2,\"REC READ\",\"+639321576684\",\"Ralph Manzano\",\"16/04/25,21:51:33+32\"";
    char delimiter[] = ",";

    // initialize first part (string, delimiter)
    char* ptr = strtok(string, delimiter);

    while(ptr != NULL) {
        printf("found one part: %s\n", ptr);
        // create next part
        ptr = strtok(NULL, delimiter);
    }

    return 1;
}

Outputs:

found one part: 2
found one part: "REC READ"
found one part: "+639321576684"
found one part: "Ralph Manzano"
found one part: "16/04/25
found one part: 21:51:33+32"

You could try to use strtok. Code from my mind and not tested:

#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
    char string[] = "AT+CMGL=\"ALL\"\n"
    "\n"
    "+CMGL: 2,\"REC READ\",\"+639321576684\",\"Ralph Manzano\",\"16/04/25,21:51:33+32\"\n"
    "Yow!!!\n"
    "\n"
    "OK\n";
    char delimiter[] = ",\n";

    // initialize first part (string, delimiter)
    char* ptr = strtok(string, delimiter);

    while(ptr != NULL) {
        printf("found one part: %s\n", ptr);
        // create next part
        ptr = strtok(NULL, delimiter);
    }

    return 1;
}

Outputs:

found one part: AT+CMGL="ALL"
found one part: +CMGL: 2
found one part: "REC READ"
found one part: "+639321576684"
found one part: "Ralph Manzano"
found one part: "16/04/25
found one part: 21:51:33+32"
found one part: Yow!!!
found one part: OK
Source Link

You could try to use strtok. Code from my mind and not tested:

#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
    char string[] = "2,\"REC READ\",\"+639321576684\",\"Ralph Manzano\",\"16/04/25,21:51:33+32\"";
    char delimiter[] = ",";

    // initialize first part (string, delimiter)
    char* ptr = strtok(string, delimiter);

    while(ptr != NULL) {
        printf("found one part: %s\n", ptr);
        // create next part
        ptr = strtok(NULL, delimiter);
    }

    return 1;
}

Outputs:

found one part: 2
found one part: "REC READ"
found one part: "+639321576684"
found one part: "Ralph Manzano"
found one part: "16/04/25
found one part: 21:51:33+32"