c - Convert from char * to int -


i have string char * = '343'. want convert integer value.

example. char *a = "44221" want store value into int a;

this should

#include <stdlib.h>  inline int to_int(const char *s) {     return atoi(s); } 

just in case example usage

int main( int ac, char *av[] ) {     printf(" to_int(%s) = %d " ,av[1] , to_int(av[1]) );     return 0; } 

Comments

  1. Nice Post. keep it up. Other wise If If Any one who want learn C++ & Advance contact us on 9311002620 or visit :- https://htsindia.com/Courses/embedded-systems-and-robotics/cplusplustraininginstituteinsouthdelhi

    ReplyDelete

Post a Comment

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -