Last active
November 10, 2015 15:23
-
-
Save bzdgn/168ca082cbf5bf7dd752 to your computer and use it in GitHub Desktop.
strtol Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main() | |
{ | |
char * numbers = "12 0x123 101"; | |
printf("\n%s %s", "before :", numbers); | |
// first token transformed | |
int first = strtol(numbers, &numbers, 10); | |
printf("\n%s %s", "after first :", numbers); | |
// second token transformed | |
int second = strtol(numbers, &numbers, 0); | |
printf("\n%s %s", "after second:", numbers); | |
// third token transformed | |
int third = strtol(numbers, NULL, 2); | |
printf("\n************\n"); | |
printf("%d %d %d\n", first, second, third); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment