Link to home
Start Free TrialLog in
Avatar of kherring79
kherring79

asked on

Converting a string of 1's & 0's to an int

I have a string containing 25 1's & zeros and i would like to convert this into an integer.

compiler is gcc on redhat 7.4.


thanks

kevin
Avatar of kherring79
kherring79

ASKER

actually dont worry, i have figured it out myself!
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sorry, i meant if i have a string containing 101010 i want to return the integer 42, but it doesnt matter now, i have written a little function that does it.

thanks

kevin
kherring,
The one-liner that ozo gave you will do exactly what you want. :-)
No comment has been added lately and this question is therefore classified abandoned.

If asker wishes to close the question, then refer to
https://www.experts-exchange.com/help/closing.jsp

Otherwise, I will leave a recommendation in the Cleanup topic area that this question is:
PAQed with A grade to ozo

Please leave any comments here within the next seven days. It is assumed that any participant not responding to this request is no longer interested in its final disposition.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Sunny
EE Cleanup Volunteer