Re: Converting from and INT back to ASCII character
From: ian (ib252_at_n0spam.com)
Date: 10/09/03
- Next message: lilburne: "Re: copy ctor question"
- Previous message: rossum: "Re: Stacks"
- In reply to: David Williams: "Converting from and INT back to ASCII character"
- Next in thread: Mike Wahler: "Re: Converting from and INT back to ASCII character"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 8 Oct 2003 18:31:44 -0400
Hello Dave,
to convert integer to ASCII string:
#include <stdio.h>
char szBuf[50];
int i = 123;
sprintf (szBuf, "%i", i);
to convert ASCII string to integer
#include <stdio.h>
#include <stdlib.h>
char szBuf[50] = "123";
int i;
sscanf (szBuf, "%i", &i); // method #1
i = atoi (szBuf); // method #2
to convert an ASCII character to an integer
char cCh = 'A';
int i = static_cast<int>(cCh);
to convert an integer to an ASCII character
int i = 65;
char cCh = static_cast<char>( i); // cCh is set to 'A'
"David Williams" <dswilliams@dsl.pipex.com> wrote in message
news:3f84773c$0$6631$cc9e4d1f@news.dial.pipex.com...
> Hi all, i have been able to convert an ASCII character to an INT however
im
> lost as to how to change them back. Cant find anything on the net (though
im
> probably looking in the wrong places!). Could anyone help me out?
>
> Thanks
> Dave
>
>
- Next message: lilburne: "Re: copy ctor question"
- Previous message: rossum: "Re: Stacks"
- In reply to: David Williams: "Converting from and INT back to ASCII character"
- Next in thread: Mike Wahler: "Re: Converting from and INT back to ASCII character"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|