hi Jib as you know from my other post "http://www.cplusplus.com/forum/general/182983/" this would be a C solution and not a C++.
yes my delimiters are always going to be 33 and 21.
but how can i construct the string from an array on first place using C commands?
so i basically have two step operation, first convert the array of chars into a string and then extract the numbers based on the criteria and save them into variables or int array
No, I didn't realize at the time that these two topics were the same. This a good reason to stop opening new topics when you have an existing topic already open. I suggest you stick with the other topic.
so i basically have two step operation, first convert the array of chars into a string
You said in the first post of this topic that you already have a string:
if i have a string like follows :
In C a string is an array of char terminated by the end of string character ('\0').
this post was on how to parse the string and the other post was part of the step on how to get the string in first place thats why i opened two different posts.
can we close the other one since the issue is now resolved , i couldnt use string since its c++ feature and not available in AVRGCC?
note: i have marked the other post as resolved .
I doubt that very much. The compiler in use doesn't have most of the C++ features available, such as std::string, and anything else that uses either templates or exceptions. So this will probably require a C solution.
I recommend using sscanf() to parse the string. Another option would be strtok() and atoi().
Is he using one of those pre 98 compilers, Borland perhaps? Here's the equivalent using strtok() to parse the string.
These two versions, parse that string for you. You need to apply your own logic to complete your assignment. Take some time to atleast understand this version of the program.
The only thing the iostream library is doing is printing to the console, since I doubt that your system has a console just remove the #include iostream line and the #include namespace std; line and replace the cout lines with whatever logic you need for your program. The while loop is separating the different numbers in your string to individual strings that you can use in your program.
The stream is not the point. It's just used to print the parsed value. I was hoping to demonstrate how to parse that string; I thought that was the problem.