You can not use a String function to treat integers.
First you have to convert the integer to a String:
sprintf(charvar,"%d",integervar); [sig]<p>hnd<br><a href=mailto:hasso55@yahoo.com>hasso55@yahoo.com</a><br><a href= > </a><br> [/sig]
Thank hnd,
The sub string (int string) I want to find in the string is not predefined. I want
to check if there ANY interger in the main string. Is there a way predefined method for this, of I have to do it my self.
I think you have to scan your STring for integer substrings by yourself.
But this is pretty simple.
If is definite, that the integer begins on a well defined location of your String than you can use tha atoi function to convert this String. [sig]<p>hnd<br><a href=mailto:hasso55@yahoo.com>hasso55@yahoo.com</a><br><a href= > </a><br> [/sig]
There is no predefined method for this. You will need to break the string down into individual words and then check each word to see if it id an integer.
It is pretty simple to do actually. If you want I can post some code later on that will do it.
Right now, somebody owes me a beer and Im going to collect. Heh.
I think sidalla's problem is to :
1) find if there is any integer in the given string.
2) If yes then convert it to integer value:
If I am right then,
Do this way.
1) Scan the string for integer's Ascii value (ie, 0-9). If found then find how big is the integer. If it can fit into the computer's integer limit. Then,
2) get the substring out of that .
And convert it to integer by any method : like
atoi, sprintf..
Does this answer your question?
Thanks
Siddhartha Singh [sig]<p>Siddhartha Singh<br><a href=mailto:siddhu_singh@hotmail.com>siddhu_singh@hotmail.com</a><br><a href=siddhu.freehosting.net> </a><br> [/sig]
To expand a little on what has been said, I think the OP is looking for a function that scans through an arbitrary length string for one or more sequences of numbers. For each sequence found, convert the sequence to an integer.
If this is close to what you want, below is something that might help you get started. Please keep in mind that this has NOT been compiled and tested (no C compiler on this comp , so there may be errors. This could certainly be improved to provide better functionality (maybe store the numbers in a user-supplied array instead of just printing the values) and it lacks bounds checking (to make sure the number is suitable for an int).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.