The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 integer to ascii character

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
peter.cook Posted - 11/15/2004 : 04:46:26 AM
Origin Version (Select Help-->About Origin): 7.5 SR5
Operating System: Win2000

Hi,

Is there a way of converting an integer to the actual ascii character eg loop 1 to 26 to output a,b...z etc. with Origin C?

Thanks,

cheers,

Pete

4   L A T E S T    R E P L I E S    (Newest First)
peter.cook Posted - 11/16/2004 : 06:53:11 AM
Hi,

Thanks for this - it is slick.

Both methods will have their uses in other apps.

Cheers,

Pete

eparent Posted - 11/15/2004 : 10:56:02 AM
Hello Peter here are two macros that will be more efficient.
I have also included two functions that show how to use the macros.


#define GET_UPPER_CASE_LETTER(n) ((char)((n) - 1 + 'A'))
#define GET_LOWER_CASE_LETTER(n) ((char)((n) - 1 + 'a'))
void OutputUpperCaseLetters()
{
for( int n = 1; n <= 26; n++ )
printf("%c\n", GET_UPPER_CASE_LETTER(n));
}
void OutputLowerCaseLetters()
{
for( int n = 1; n <= 26; n++ )
printf("%c\n", GET_LOWER_CASE_LETTER(n));
}



peter.cook Posted - 11/15/2004 : 10:48:59 AM
Thanks for the assist Ruthven.
Probably a more useful & flexible approach for my purposes anyway.

Cheers,

pete

rlewis Posted - 11/15/2004 : 10:20:30 AM
Try the following ...


void CharToInt()
{
vector<byte> Characters={'A','B','C','D','a','b','c','d'};
vector<int> Numbers;
Numbers=Characters;
string strOutPut;
int MyInt;
for (int i=0; i<8; i++)
{
char MyChar[1]=Characters[i];
MyInt=Numbers[i];
strOutPut.Format("%s,%d",MyChar, MyInt);
out_str(strOutPut);
}
}

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000