Hi I am a bit new to this field and came across a small problem.I tried to find the solution for almost 2 days and havent been able to.I hope some one there can help.I am sure its a small things but just cant get it right.
Well I have some things like
s=12,56,3,4 \\s is a string
I have to take out the values i.e 12,56,3 and 4 and convert to integer values.The limit is the comma.I tried to use something to find how many numbers are before the comma and extract it.but is didnt work as it started from the begining always.The number is always integer and there is no double or any other type.
So simply how to get the values from a string to an integer where it is seperated by a comma?
Thanks
5 2106
Are these values held in a string (i.e. std::string) or are they in a character array (i.e. char string[])?
Hi I am a bit new to this field and came across a small problem.I tried to find the solution for almost 2 days and havent been able to.I hope some one there can help.I am sure its a small things but just cant get it right.
Well I have some things like
s=12,56,3,4 \\s is a string
I have to take out the values i.e 12,56,3 and 4 and convert to integer values.The limit is the comma.I tried to use something to find how many numbers are before the comma and extract it.but is didnt work as it started from the begining always.The number is always integer and there is no double or any other type.
So simply how to get the values from a string to an integer where it is seperated by a comma?
Thanks
use strtok() function, and , as a delim and after use atoi function.
If your delimiter is a space (' '), then you can use the C++ streams (fstream and stringstring) to parse the data directly into your variables. What do you prefer?
Hi
thanks for the info above.Well to make the story clear I am working on a software to connect a SMU(a machine to measure the properties of a sub micron chip) to its software.I have the idea for the software but just cant get it translated.
Well we enter the number of pins to connect to each wafer like 3,12,7,19 etc.And so i just have to change it to an integer so as to transfer it to a different machine trough GPIB.I have finished that part.So all that remains is to convert this string with integer values to an integer
string initial;
int chan11,chan12,chan13,chan14;
initial=23,12,7,8;
chan11=23;
chan12=12;
chan13=7;
chan14=8;
I tried to use itol in a loop but didt work it gave some rubbish values.I know for integer we can use something like;
int j=11;
for(i=0;i<10;i++)
{
if(string[i]!=',';//if is a ,
chan[j]=chan[j]*10+string[i];//eg:chan 11=2*10+3=23
}
else
{
j++; //chan 11 is now chan 12
}
Something like this.Thanks for the time again:-)
Hi all;
Thanks for all those who helped.I managed to finish it with strtok() function to convert to character and then to integer with itoa() function with information from various threads in this website.
Thanks a lot
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Pikkel |
last post by:
i'm looking for a way to replace special characters with characters
without accents, cedilles, etc.
|
by: Vladimir |
last post by:
Method UnicodeEncoding.GetMaxByteCount(charCount) returns charCount * 2.
Method UTF8Encoding.GetMaxByteCount(charCount) returns charCount * 4.
But why that?
Look:
/*
Each Unicode character...
|
by: David Mathog |
last post by:
Every so often one of my fgets() based programs encounters
an input file containing embedded nulls. fgets is happy to
read these but the embedded nulls subsequently cause problems
elsewhere in...
|
by: Jon S via DotNetMonster.com |
last post by:
Hi all,
I posted this yesterday but didnt explain it too well so thought I would do
it again.
I have a label on a form that I want to be able to change the text while I'm
in a seperate class...
|
by: SMG |
last post by:
Hi All,
I have created an application which is working fine and is in about to
launch, now suddenly my mgmt says there are chances that Scrip ID( a
particular id and not prim key) may have special...
|
by: Ron L |
last post by:
I have a barcode scanner which uses a "keyboard wedge" program so that the
data it scans comes through as if it was typed on a keyboard. I am trying
to have the data in the barcode be displayed in...
|
by: randy1200 |
last post by:
Using Visual Studio 2005.
I'm using XmlReader to read data into a string variable in C#. Works great!
Every once in a while, I see that the string data contains a symbol that
looks like a...
|
by: Antoninus Twink |
last post by:
Or, just how low has this group sunk?
Twice in the past couple of days, Default Loser has accused Chris Hills,
member of the ISO C committee, of being a troll (though given that the
former's...
|
by: desertavataraz |
last post by:
I am going write an application in C++ that allows the user to see two languages at once, and allows them to search each individual language for words or keywords. I have a font that I made...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |