Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Promoting unsigned long int to long int
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="pereges, post: 3580972"] btw i want to read a string containing 3 numbers: "1234 3333 6666" SO the logic I used was unsigned long l1, l2, l3; char s[] = "1234 3333 6666" char *endptr1, *endptr2 errno = 0; l1 = strtoul(s, &endptr1, 10); l2 = strtoul(&endptr1, &endptr2, 10); l3 = strtoul(&endptr2, NULL, ), 10); if (errno == ERANGE) { if (l1 == ULONG_MAX || l2 == ULONG_MAX || l3 == ULONG_MAX) { /* do the error handling */ } } else { if (s == endptr1 || endptr1 == endptr2) { printf("Conversion failed"); return (1); } } [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Promoting unsigned long int to long int
Top