Convert String To To Int C Code Example


Example 1: string to int c


atoi(str) is unsafe

This is the prefered method:
(int)strtol(str, (char **)NULL, 10)

Example 2: how to cast string to int in c


use atoi from the stdlib.h 
char *string = "hi";
int x = atoi(string);

Comments

Popular posts from this blog

530 Valid Hostname Is Expected When Setting Up IIS 10 For Multiple Sites

C Perror Example

Converting A String To Int In Groovy