Hi. I have such a question, how can I convert some char into int?
Example: char a ='5';
and I need to get the same "5" but int type. And if it's possible, then actually is required some how from type string or char convert 2 chars to int value(for example convert "35" to int 35.
Can someone help please?
7 30030
Hi. I have such a question, how can I convert some char into int?
Example: char a ='5';
and I need to get the same "5" but int type. And if it's possible, then actually is required some how from type string or char convert 2 chars to int value(for example convert "35" to int 35.
Can someone help please?
int aa = '5';
For your second question, lookup atoi(), atof() or sscanf().
Adrian
Oh, really, I forgot about "atoi()" function. Thanks.
Hi. I have such a question, how can I convert some char into int?
Example: char a ='5';
and I need to get the same "5" but int type. And if it's possible, then actually is required some how from type string or char convert 2 chars to int value(for example convert "35" to int 35.
Can someone help please?
If the char is between 0-9 you can use this: -
char mychar = '2';
-
int myint = mychar - '0';
-
If it's a bigger number however, you can use the atoi() function: -
char mychar[] = "35";
-
int myint = atoi(mychar);
-
Is that what you're looking for?
Oops, too late. sorry Adrian
Oops, too late. sorry Adrian
No need to appologies. The more that help, the sooner they get help. ;)
Adrian
Banfa 9,065
Expert Mod 8TB
For your second question, lookup atoi(), atof() or sscanf().
My preference for a conversion function is strtol (or strtoul) because you are able to tell if and how things went wrong (if and when they go wrong) using this funcation as opposed to atoi.
My preference for a conversion function is strtol (or strtoul) because you are able to tell if and how things went wrong (if and when they go wrong) using this funcation as opposed to atoi.
Cool, I'll have to rember that one. I usually use scanf and its relitives for that same reason.
Adrian
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Markus Hämmerli |
last post by:
I ' ll tra to convert a Cstring to char* without success.
I working in a Unicode enabled environment
this is working in Unicode
CString source = _T("TestString");
TCHAR *szSource =...
|
by: Sam Smith |
last post by:
Hi,
I wan't a function to take a const char*, a start bit position and number of
bits and convert that bit-stream into a primitive of desired type.
I.e. something like:
char convert(const...
|
by: Brad Moore |
last post by:
Hey all,
I'm getting the following compiler error from my code. I was wondering
if anyone could help me understand the concept behind it (I actually did
try and compile this degenerate...
|
by: whatluo |
last post by:
Hi, all
I'm now working on a program which will convert dec number to
hex and oct and bin respectively, I've checked the clc but with no
luck, so can anybody give me a hit how to make this done...
|
by: MilanB |
last post by:
Hello
How to convert char to int?
Thanks
|
by: Yifan |
last post by:
Hi
Does anybody know how to convert System::String* to char*? I searched the System::String class members and did not find any. Thanks
Yifan
|
by: caramel |
last post by:
i've been working on this program forever! now i'm stuck and going
insane because i keep getting a syntax error msg and i just can't see
what the compiler is signaling to!
#include <stdio.h>...
|
by: Eric BOUXIROT |
last post by:
hi,
i must convert all of these eVC++ prototypes to use with VB.NET....
DLLEXPORT long F_BDO_MessageBoxOK(char *IN_title, char *IN_msg );
DLLEXPORT long F_BDO_MessageBoxOUINON(char *IN_title,...
|
by: GRoll35 |
last post by:
I get 4 of those errors. in the same spot. I'll show my parent class,
child class, and my driver.
All that is suppose to happen is the user enters data and it uses
parent/child class to display...
|
by: Zytan |
last post by:
I am surprised that a single character string is not auto-created from
a single char. It is hard to find information on converting a char
into a string, since most people ask how to convert char...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |