From int to char...

Got a nice little problem: I have an int (e.g. int i = 111). This should be transformed into the appropriate ASCII-Code char (or UNICODE-char, if only this is possible). Sounds easy but I didn't manage it.
In desperate need for help... :-)
Hannibal_
Thanx!

Have you ever tried to cast an int to char? I've tried it for hours now but I didn't get it right. There is no problem to specify a char by giving it an int value (char c = 111) but to cast an int to char. It's not possible to do it like this:
char c;
int i = 111;
c = i;
Thanx!

Similar Messages

  • Convert from int to char

    Hi,
    How can I convert from an int to char?

    The challange is to convert from int to String without using any API or automatic conversionWoah, what a challenge ! Why ?
    Anyway, what about a recursive call and switch statement. Something likepublic String intToString(int n) {
        if(n<0) {
            return "-"+intToString(-n);
        if(n<10) {
            return getStringDigit(n);
        else {
            return intToString(n/10) + getStringDigit(n%10);
    private String getStringDigit(int n) {
        switch(n) {
            case 0:
                return "0";
            // etc.
    }

  • How to call labview DLL from C#, passing char, char[], float[], long, short

    Hi,
    I'm having trouble calling labview dll from C# to perform certain function.
    The function supposed to return the values in the float Analysis[] array. However, when I execute it it only returns zero values.
    It seems that some parameters are not properly passed to the dll.
    Below is the function in the header file:
    void __stdcall Optical_Center(char FileDirectory[], long ImagePtr,
        short int Height, short int Width, char ReadFromFile, float Analysis[],
        long lenAnalysis);
    and my corresponding dll import in c#:
    [DllImport(@"SMIA.dll", CharSet = CharSet.Ansi)]
            public static extern void Optical_Center([MarshalAs(UnmanagedType.LPStr)]string FileDirectory, long ImagePtr,
                short Height, short Width,char  ReadFromFile, IntPtr Analysis,
                long lenAnalysis);
    string str = @"C:\SMIA.raw";
    int len = 3;
    long m_lenAnalysis = 3;
    long m_ImagePtr = 0;
    short m_Height = 2464;
    short m_Width = 3280;
    IntPtr m_PtrArray = Marshal.AllocHGlobal(len * Marshal.SizeOf(typeof(float)));
    char m_ReadFromFile = '1';
    Optical_Center(str,m_ImagePtr,m_Height,m_Width,m_ReadFromFile,m_PtrArray,m_lenAnalysis);
    float[] m_Analysis = new float[len];
    Marshal.Copy(m_PtrArray, floatArray,0,len);
    Marshal.FreeHGlobal(m_PtrArray);
    string printstr = "";
    for (int i=0; i<len; i++)
        printstr = printstr + floatArray[i].ToString() + "\n";       
    MessageBox.Show(printstr);
    Appreciate if anyone can help, thanks.
    KL

    I was just about to post the header file of the DLL, when
    I noticed that there's a function called LVDLLStatus.
    This little thingie turned out to be a rather handy tool.
    With that function I found that in the DLL I had a problem
    with another function that prevented the DLL to be correctly
    loaded.
    This other function in the DLL is for generating digital output
    and it worked as it should, when tested from LV.
    Anyway if someone is interested, I got it working by using
    the LoadLibrary and GetProcAddress function, as in the
    source code thatI posted earlier.
    I will investigate what is wrong with that digital output, and
    post into a another thread if I have problems with that.

  • How to Change the data type of infoobject from NUMC to CHAR

    Hi Experts,
    I have created an infoobject with data type as NUMC, i used in DSO as a key figure and i have loaded data up to PSA.
    Now i want to change the data type of this Info Object from NUMC to CHAR.
    Can anyone suggest me the solution for this issue.
    Regards,
    Venu Gopal.K

    Hi pavan/binu,
    I have not loaded data into DSO i just added IO in Key fields and i started editing this IO then im facing error like
    1.Master Data Table /BIC/PZCUSTOMER contains data: Characteristic ZCUSTOMER cannot be activated     
    2.SID Table /BIC/SZCUSTOMER contains data: Characteristic ZCUSTOMER cannot be activated
    Im also unable to edit the P & S tables in SE14.
    NOTE:I have data only in PSA and when im trying to load data to DSO Im facing these issues.

  • Convert from int to String

    Hi, may i know how to convert from int to String??
    For instance, i've>>
    int i = 0;
    i++;
    String temp = i.toString();
    [Need to convert the int to String here. Am i doing the convertion correctly?? Pls correct me. Thanks!]

    Hi, may i know how to convert from int to String??
    For instance, i've>>
    int i = 0;
    i++;
    String temp = i.toString();
    [Need to convert the int to String here. Am i doing
    the convertion correctly?? Pls correct me. Thanks!]String temp = "" + i;

  • Convert from jchar to char

    Does any one know how to convert from jchar to char?
    Thank you,

    does it have to be a jchar or can you get a jstring? is it possible to convert your jchar into a jstring before you pick it up in jni? if you can get a jstring you can use the function
    const char* GetStringUTFChars(jstring str, jboolean *isCopy)
    you would get back a character pointer that points to a single char plus the null terminator

  • Typecasting int into char

    I've got a method I'm working on that looks like this:
    private static String generatePassword()
    String pass = "";
    int randomInt;
    char a;
    for(int i = 1; i <= PASSWORD_LENGTH; i++)
    randomInt = generator.nextInt();
    a = (char)randomInt;
    pass = pass + a;
    System.out.print(pass);
    return pass;
    What I'm trying to do here is create a randomly generated password that consists of five characters. Password_Length is a static variable set to 5. I'm having a problem typecasting the randomInt into a character. Everytime I do this, my display comes back as 'boxes' for each character. If anyone can help, it'd be appriciated.

    private static String generatePassword()
    String pass = "";
    int randomInt;
    char a;
    for(int i = 1; i <= PASSWORD_LENGTH; i++)
                  randomInt = (int)(((double)('z'-'a'))*java.lang.Math.random());
                  if(java.lang.Math.random()<0.5)
                      randomInt -= ('a'-'A');
    a = (char)randomInt;
    pass = pass + a;
    System.out.print(pass);
    return pass;
    }

  • Fact table data type changed from int to nvarchar -- rebuild on cube fails

     I change one of my data types in the Fact table from INT to Nvarchar... When I look at the properties it appears
    correct but when I try to Process it fails still thinking it's data type INT.
     How can the DSV be refreshed( I did try REFRESH  and it noticied the change to field) to reflect new nvarchar data type without
    having to rebuild entire Cube.
    SSAS 2005
     Thanks.

    Did you try to view the code on the Data Source view and cube that it is reflecting the correct data type on both places? if not you can change there and save it.
    prajwal kumar potula

  • NLS_LENGTH_SEMENTICS from BYTE TO CHAR

    Hi,
    For supporting multibyte character, we need to change NLS_LENGTH_SEMENTICS parameter from BYTE to CHAR. But this parameter setting will effect for new database tables created thereafter. To change the storage characteristics for existing database tables we explicitly executed Alter statements for database tables for columns having datatype as “Varchar2” and “Char”.
    Problem:
    ======
    Since the number of database tables in PRODUCTION are very high and contains approx. 600 million of records spread over 400 database tables, we are not in a position to afford the time which will be spent in altering these database tables in PRODUCTION.
    We ran the test by alter script in System Test environment and alteration of database tables covering 150 tables and 200 million of records was carried out in almost 16-20 hrs.
    APPROACHES WE HAVE IN MIND
    ==========================
    1. Alter all the table columns (We tried the same and taking too much time)
    2. Export /Import with NLS_LENGTH_SEMENTICS set as CHAR(We discuss with our DBA about this approach and found that it will also take too much time and there is RISK of data inconsistency)
    3. Drop the index of the table, run alter script for changing storage type BYTE to CHAR , and rebuild the index (this is also taking too much time).
    All above approaches are very costly in terms of time, that we cannot afford.
    If any one having better solution then please suggest.
    thanks in advance
    Syed

    Hi
    We are also facing a similar problem
    We ran alter table scripts and now compiling the objects
    and that is taking lot of time.
    we have around 4000 invalids that by parallel recomp came down to 2000 but still these 2000 which are mostly packages .. are giving a hard time.
    if anyone has faced/found a similar issue/solution pls post. or maildirectly to me.
    Sunil Choudhary

  • Int to Char...I don't know what the problem is here

    Everything compiles fine here, and if I print out the "encryption" variable I get what looks like it would be right, converted into chars, but when I try to convert the int to char(my char variable for that is 'w'), my compiler freaks out, I don't even know what it's doing it doesn't give me an error, but sometimes it prints out nothing but sometimes it prints out "puTTypUTtypuTTYPUtty" ...why is it doing that and what is wrong with what I am doing?.
    public class encrypt
    public static void main(String[] args)
    String plainText = "hello, my name is christy.";
    String keyWord = "nice to meet you";
    int encryption = 0;
    char ch = 'a';
    char c = 'a';
    int encryptor = 0;
    int charCode;
    int sum = 0;
    char w;
    int i = plainText.length();
    int j = plainText.length();
    int[] plain = new int;
    int[] key = new int[j];
    for(i=0; i<plainText.length(); i++)
    ch = plainText.charAt(i);
    charCode = (int)ch;
    if(charCode > 97 && charCode < 122)//make lowercase
    {charCode = charCode - 97;}
    if(charCode > 65 && charCode < 90)
    {charCode = charCode - 65;}
    plain[i] = charCode;
         for(j=0; j<keyWord.length(); j++)
    c = keyWord.charAt(j);
    int chCode = (int)c;
    if(chCode > 97 && chCode < 122)
    {chCode = chCode - 97;}
    if(chCode > 65 && chCode < 90)
    {chCode = chCode - 65;}
    key[j] = chCode;
    encryption = (plain[i] + key[j]) % 26;
    w = (char)encryption;
    System.out.print(w);

    And for that matter, use increment/decrement assignment operators (like += and -=) instead of verbosely repeating the variable. And if you're going to use character-by-character case conversion, use the methods in Character don't do it like a C programmer circa 1982. And if this is anything other than a homework assignment, use encryption code provided in the JDK; don't reinvent it.

  • I want to have firefox use my Homepage from Int Explorer

    when I was installing firefox there was an option to copy my homepage from Int Explorer. how do I do this now ?

    Just set the homepage that you want in Firefox.
    http://support.mozilla.com/en-US/kb/How+to+set+the+home+page

  • HOW TO MOVE DATA FROM INT-TABLE TO DATABASE STRUCTURE?

    DEAR ALL!
    CAN ANY ONE GIVE ME SAMPLE CODE TO MOVE DATA FROM INT -TABLE TO DB-STRUCTURE PLEASE.
    I HAVE THE VALUES IN TABLE AND I NEED TO UPDATE STRUCTURE.
    REGARDS,
    VJ

    Hi,
       If you want to update a db STRUCTURE it is not possible because Structure doesnot hold any data.
    If you are trying to update a db table  then the update command should do the work.
    Eg : UPDATE VBPA3 FROM TABLE DA_XVBPA3U.
    Note :  The Internal table should be of same structure and should not have duplicate entries.
    Regards,
    Srini.

  • Necesito saber cual es la instrucion que me convierte un int a char es decir lo contrario a la instrucion atoi ya que necesito convertir el entero a cadena para utilizar ese dato en la instrucion SetCrtlval

    Necesito saber cual es la instruccion en cvi que convierte int a char

    Usa sprintf(char Destino, const char Formato, origen_de_datos), que esta en la libreria ANSI C. Es una funcion general que genera un string de chars con cualquier tipo de datos.
    Debes declarar un char Destino del largo necesario para que contenga todo el numero (aprox. 6 caracteres para un int). El char formato es del tipo "%d" para un entero
    Ej
    int Entero;
    char EnteroConvertido[6];
    sprintf(EnteroConvertido,"%d",Entero);

  • Is there a way to automatically build measure object with SUM(col_name) from INT DB column?

    Hello,
    I have a workflow that needs to be repeated every month and I'd like to optimize it.
    1. DB table in SQL Server 2008 looks something like this:
    TABLE [CONTRACTS_GCO_LVL2](
      [CONTRACTS_BP_ID] [varchar](50),
      [Flag 1] [int] ,
      [Flag 2] [int] ,
      [Flag 3] [int] ,
    2. I bring this table into my BOE IDT 4.0.3 and drag it into object folder. All INT columns become dimensions. This is not what I want. These are 1/0 flags for me and I need them to be measures with SUM aggregation.
    3. I select all these INT sourced dimensios and right click on them with "Turn into measure with aggregation function - SUM"
    The problem is that step #3 is unbelievably slow. I need to spend hours doing this as I have thousands of these flags. I end up selecting all dimensions from one screen and converting them at the same time. This takes 4-5 minutes. IDT runs on a Win 2008 R2 Enterprise server with 32 GB RAM and 4 CPUs.
    In Universe Designer there used to be external strategies that allowed some customization of how the objects get automatically created from DB tables. I know there are no strategies in r4 (External strategy for tables)  but is there anything else to make this process faster?
    Thank you all!
    Natasa

    Hrm, I'm suspecting that perhaps it has to do something with setting CHAR fields. Some of the fields in this table are CHAR but I don't see a call in my PreparedStatement that can set a char, only a String, so that's what I've been using, but it may be that that's not the right thing to do. I'm running Java 1.5.10, and looking through the API there doesn't seem to be anything specifically for char.

  • Int to char

    Hello,
    How can I convert an int variable representing a character to a char variable?
    Thanks.

    Nononono; you must get it straight: as everybody well
    knows the Lewis/Clark
    approach suffers from negative zeros in their one
    complement scheme; that's
    why the latest JTCAPI abondoned it in their final
    draft proposed at the JCP#56632
    sabre and I are right and you are dead wrong; so
    there :-P
    kind regards,
    JosI'll never never never never never never never believe you, no matter how many times you damn oligarchs post the truth, no matter how many times you back it up with supporting references. NA NA NA NA NA NA NA I CAN'T HEEEAAAR YOUUUU!
    World spins
    RD-R
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for

  • .pdf file not opening in Illustrator CS5

    All of a sudden, I cannot get ,pdf files to open in Illustrator CS5. what would cause this? Thanks

  • Noob Question: T400 Switchable Graphics?

    Just got my T400 this weekend, and I have a question about the switchable graphics feature. I can't actually find any way to control the switchable graphics.  I see the different battery life options and that type of thing, but is there anything that

  • Send picture to exe application

    Hi, all I'm now doing a project which have to send picture or frame in mc to external exe application and let it save those picture into jpg or other supported format. Is this possible to make ? Regards, Mephisto

  • Celtx - Need guidance with first PKGBUILD

    Ok, I decided to make my first PKGBUILD, and chose Celtx (http://celtx.com/) since it seems like a very useful tool, and not too complicated.  I already installed it manually and it works fine. However, although they state it's open source, the sourc

  • Is it possible to retrieve user claims in an event receiver?

    We have a custom list where we want to store the claims information of the user on the item adding event. Is this possible with an event receiver? Are there any examples? Thanks.