Will atoi() convert the convertible characters in a string? I mean, in this problem,
post[20]="822*/3+2"
, if i write
atoi(post)
, will it convert the numerical characters to int? And how about the operators?
Will atoi() convert the convertible characters in a string? I mean, in this problem,
post[20]="822*/3+2"
, if i write
atoi(post)
, will it convert the numerical characters to int? And how about the operators?
Here's what the man pages have to say:
int atoi(const char *nptr);
DESCRIPTION
The atoi() function converts the initial portion of the string pointed
to by nptr to int. The behavior is the same as
strtol(nptr, (char **) NULL, 10);
except that atoi() does not detect errors.
You really should write a small program and see what it returns.
Ok, i'll try strtol(), correct me if i'm wrong.
nptr is the string
what about (char**)NULL?
and that 10
Ok, i'll try strtol(), correct me if i'm wrong.
nptr is the string
what about (char**)NULL?
and that 10
You really should try Googling..What your asking is can be found by typing
c programming strtol
in your browser.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.