strtol Questions
17
Solved
In C, what is the most efficient way to convert a string of hex digits into a binary unsigned int or unsigned long?
For example, if I have 0xFFFFFFFE, I want an int with the base10 value 429496729...
Shawanda asked 13/8, 2008 at 20:20
8
Solved
What is the difference between atol() & strtol()?
According to their man pages, they seem to have the same effect as well as matching arguments:
long atol(const char *nptr);
long int strtol(...
1
Solved
#include <cinttypes>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
uint64_t descendingOrder(uint64_t a)
{
string str = to_string(a);
sort...
3
Solved
I can use the strtol function for turning a base36 based value (saved as a string) into a long int:
long int val = strtol("ABCZX123", 0, 36);
Is there a standard function that allows the inversi...
1
Solved
1
Solved
Consider the following:
#include <iostream>
#include <cstdint>
int main() {
std::cout << std::hex
<< "0x" << std::strtoull("0xFFFFFFFFFFFFFFFF",0,16) << std:...
2
Solved
I've been trying to properly convert a char array to a long with strtol, check if there was an overflow or underflow and then do an int cast on the long. Along the way, I've noticed a lot of ...
5
Solved
I have been using std::atoll from cstdlib to convert a string to an int64_t with gcc. That function does not seem to be available on the Windows toolchain (using Visual Studio Express 2010). What i...
2
I am writing a c program to be run on UNIX, and attempting to utilize the chmod command. After consulting the man pages, i know that chmod needs two parameters. first is the permission bits, second...
Cindacindee asked 27/11, 2013 at 9:9
3
Solved
I met some unexcepted result of strtol in c
Here is the sample program.
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("%x\n", strtol("0xfffff...
Stoller asked 23/5, 2013 at 10:24
1
Solved
Here is how strtol has to be declared according to § 7.22.1.4 from C11 (n1570):
#include <stdlib.h>
long int strtol (const char *restrict nptr,
char **restrict endptr,
int base);
As far...
Quicksand asked 14/2, 2013 at 16:39
4
Solved
I am really confused. I have to be missing something rather simple but nothing I am reading about strtol() is making sense. Can someone spell it out for me in a really basic way, as well as give an...
3
Solved
This code seems to work as expected, populates an array of numbers using a single pointer
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
int main(void)
{
int arr[4],...
6
Solved
Out of professional curiosity, what is the safest / fastest / most efficient way to compare two fully numeric strings in C?
#include <stdio.h>
#include <string.h>
#include <stdlib.h...
6
Solved
I can do this:
int main(int argc, char** argv) {
unsigned char cTest = 0xff;
return 0;
}
But what's the right way to get a hexadecimal number into the program via the command line?
unsigned ...
Assail asked 29/1, 2010 at 15:15
4
The specification for strtol conceptually divides the input string into "initial whitespace", a "subject sequence", and a "final string", and defines the "subject sequence" as:
the longest initi...
Proconsul asked 14/7, 2011 at 23:17
5
Solved
The following code does not give a warning with g++ 4.1.1 and -Wall.
int octalStrToInt(const std::string& s)
{
return strtol(s.c_str(), 0, 8);
}
I was expecting a warning because strtol re...
1
© 2022 - 2024 — McMap. All rights reserved.