473,395 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How do i convert a char to int?

is there any way that i could convert a character from a string to an integer in an array?

like,

String a = "1110";

and convert it to:

int b[] = {1,1,1,0};
Feb 5 '08 #1
7 3037
BigDaddyLH
1,216 Expert 1GB
is there any way that i could convert a character from a string to an integer in an array?

like,

String a = "1110";

and convert it to:

int b[] = {1,1,1,0};
What have you tried so far? I can think of several ways to do it.
Feb 5 '08 #2
Nepomuk
3,112 Expert 2GB
is there any way that i could convert a character from a string to an integer in an array?

like,

String a = "1110";

and convert it to:

int b[] = {1,1,1,0};
You might want to have a look at the Character, the String and the Integer API entries.

Greetings,
Nepomuk
Feb 5 '08 #3
r035198x
13,262 8TB
You might want to have a look at the Character, the String and the Integer API entries.

Greetings,
Nepomuk
I was beginning to think the terrorists had kidnapped you again.
Feb 6 '08 #4
Nepomuk
3,112 Expert 2GB
I was beginning to think the terrorists had kidnapped you again.
Na, just didn't have much time for programming in the last few months and therefore never checked what was going on here... But now I have a new little project and when I wanted to check something up, guess where I went? ^^

Greetings,
Nepomuk
Feb 6 '08 #5
vinothg
21
How about this ...

String s = "" + 1110;
int[] b = new int[4];
for(int i=0; i<s.length();i++) {
int d =Integer.parseInt(""+ s.charAt(i));
b[i]=d;
}
Feb 6 '08 #6
Nepomuk
3,112 Expert 2GB
How about this ...
Expand|Select|Wrap|Line Numbers
  1. some code I won't quote
Now, that's most certainly spoon feeding. By the way, that will work for the number 1110, but it's not really a generic answer and as I don't think, the program will only ever be confronted with 1110, it's not much use.

Greetings,
Nepomuk
Feb 7 '08 #7
vinothg
21
I showed this as an example. If i put this is a function which accepts an int and use that paramter in place of 1100 it will be generic.
Feb 7 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

6
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 =...
1
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...
5
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...
7
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...
7
by: MilanB | last post by:
Hello How to convert char to int? Thanks
15
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
19
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>...
3
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,...
12
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...
5
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.