hi , im pretty new to computer science and alose to this community . i have a problem that im trying to solve and hope you guys can help me with it . im trying to create my own version of the function "atoi" that can be found in stdlib and i cant get it to work . i know how to convert a single char from the string to and int , but its starting to be a problem when im trying to convert a number like "111" , if any1 can help it could be great . thanks ...
RisTar 0 Junior Poster in Training
Recommended Answers
Jump to PostTo convert a single character to an int just simply subtract '0' from its ascii value
char c = '1'; int num = c - '0';
When converting several characters to int you have to multiply the previous value by 10 to make room for the new …
All 3 Replies
thekashyap 193 Practically a Posting Shark
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
RisTar 0 Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.