i am using gsm modem ! I USE CMGL COMMAND TO DISPLAY THE
LIST OF MESSAGES ! I WANT TO READ EACH MESSAGE ONE BY ONE
AND GET EACH MESSAGE INDEX USING C PROGRAM ! THE RESPONSE OF
THE MODULE AFTER AT+CMGL IS
---CMGL: 1,"REC
READ","+85291234567",,"07/05/01,08:00:15+32",145,37
It is easy to list SMS text messages.----
I WANT THE PROGRAM TO GET THE NUMBER "37"{MESSAGE LENGTH}
AS WELL AS "1"(MESSAGE INDEX NUMBER"
PLEASE HELP



i am using gsm modem ! I USE CMGL COMMAND TO DISPLAY THE LIST OF MESSAGES ! I WANT TO READ EACH ME..

Answer / senthil

assume the read message string is stored in a buffer buf already

char buf[100] = "CMGL: 1,\"REC READ\",\"+85291234567\",,\"07/05/01,08:00:15+32\",145,37";
int comma_cnt = 0, i, j;
char msgidx[10];
char msglen[10];

if(strncmp("CMGL:", buf, 5) == 0)
{
// copy message index till comma
for(i=5, j=0; buf[i] != ','; i++)
{
msgidx[j++] = buf[i];
}
msgidx[j] = 0;

i++; // loc after comma;
comma_cnt = 1;

for(; buf[i] != 0; i++)
{
// check for commas
if(buf[i] == ',')
{
// check for 7th comma
if(++comma_cnt == 7)
{
comma_cnt = 0;
strcpy(msglen, buf+i+1);
printf("message index = %s\n", msgidx);
printf("message length = %s\n", msglen);
}
}
}
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

What are the different types of control structures?

0 Answers  


Explain union. What are its advantages?

0 Answers  


Write a program that his output * *** *****

1 Answers  


All technical questions

0 Answers   TCS,


Can we declare function inside main?

0 Answers  






Can we initialize extern variable in c?

0 Answers  


main() { int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }

5 Answers   Vector, Vector Solutions,


compare array with pointer?

1 Answers  


.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }

0 Answers  


#include<stdio.h> #include<conio.h> struct stu { int i; char j; }; union uni { int i; char j; }; void main() { int j,k; clrscr(); struct stu s; j=sizeof(s); printf("%d",j); union uni u; k=sizeof(u); printf("%d",k); getch(); } what is value of j and k.

2 Answers   Facebook,


I need to take a sentence from input and sort the words alphabetically using the C programming language. Note: This is C not C++. qsort and strtok not allowed

4 Answers   Aspire,


what are the difference between ANSI C and Let Us c and Turbo C

4 Answers   LG Soft,


Categories