Reading char* buffer
-
Hi, I have some data in char *szBuffer. I need to read the data fom the buffer nad put them into respected variable. Suppose szBuffer returns "15,30\r\n CMD OK \r\n" , then I need to keep 15 in one variable,30 in other and CMD OK in other variable. Can anyone help me how to do this. Any sample code will be good help for me. Thanks..
-
Hi, I have some data in char *szBuffer. I need to read the data fom the buffer nad put them into respected variable. Suppose szBuffer returns "15,30\r\n CMD OK \r\n" , then I need to keep 15 in one variable,30 in other and CMD OK in other variable. Can anyone help me how to do this. Any sample code will be good help for me. Thanks..
Read up on tokenizing. See
strtok()
andstrchr()
for starters."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
-
Hi, I have some data in char *szBuffer. I need to read the data fom the buffer nad put them into respected variable. Suppose szBuffer returns "15,30\r\n CMD OK \r\n" , then I need to keep 15 in one variable,30 in other and CMD OK in other variable. Can anyone help me how to do this. Any sample code will be good help for me. Thanks..
-
The standard library is your friend if you're using C++. Have a look at: - istringstream - getline and see what you can cobble together. Cheers, Ash
-
We don't do homework around here. You have been given enough hints of what to use and read up on. Try to get something wotking. If you then have problems, post your code and explain what does not work. Someone will try to help you out. Dave.