Does anyone have a function or procedure for converting integers to
character strings?
Thank you,
John 30 8681
John Carroll wrote: Does anyone have a function or procedure for converting integers to character strings?
Didn't you think this would probably be a common question? If not, then
you think you've stumbled onto unexplored territory, even though C has
been in use for a quarter century. That seems unlikely, especially for
such a common thing to do, doesn't it? So a rational person would check
the FAQ, wouldn't he? <http://www.eskimo.com/~scs/C-faq/q13.1.html>
John Carroll wrote: Does anyone have a function or procedure for converting integers to character strings?
sprintf() (or better, if you have a [somewhat] C99 compatible
compiler/library, snprintf().
But please, *get a book!!!!!*
HTH,
--ag
--
Artie Gold -- Austin, Texas http://it-matters.blogspot.com (new post 12/5) http://www.cafepress.com/goldsays
itoa()
printf()
sprintf()
John Carroll wrote: Does anyone have a function or procedure for converting integers to character strings?
Thank you, John
Neil Kurzman wrote: John Carroll wrote:
Does anyone have a function or procedure for converting integers to character strings?
Thank you, John
[top posting orrected]
itoa()
No such thing.
printf()
Nope.
sprintf()
Yup!
HTH,
--ag
--
Artie Gold -- Austin, Texas http://it-matters.blogspot.com (new post 12/5) http://www.cafepress.com/goldsays
In article <3b************ *@individual.ne t>,
Artie Gold <ar*******@aust in.rr.com> wrote: Neil Kurzman wrote: John Carroll wrote:
Does anyone have a function or procedure for converting integers to character strings?
printf()
Nope.
printf() is indeed capable of converting integers to character
strings -- it just has its own ideas about where the character
strings should end up. ;-)
If one cared to go through the bother, one could, completely
within standard C for hosted environments, open a file read/write,
printf() to produce the character string output, rewind to the
beginning of the file, and read the string in to the desired
destination buffer. Sure it'd be clunky, but conformant.
Depending on how many extensions one was willing to live with, there is
even a case in which the operation might be relatively efficient -- if
one closed stdout, nmap()'d some memory, took the fd from that [which
would be the fd normally used for stdout because of the POSIX rules
about using the first available fd], used fdopen() to pull that up to a
FILE*, and used printf() to do the desired conversion, then the result
could be read back directly from the memory area nmap'd to.
Who needs simple standard sprintf() when one can use something
complicated, not generally portable, but 3001 ? ;-)
--
Oh, to be a Blobel!
Walter Roberson wrote: In article <3b************ *@individual.ne t>, Artie Gold <ar*******@aust in.rr.com> wrote:
Neil Kurzman wrote:
John Carroll wrote:
Does anyone have a function or procedure for converting integers to character strings? printf()
Nope.
printf() is indeed capable of converting integers to character strings -- it just has its own ideas about where the character strings should end up. ;-)
If one cared to go through the bother, one could, completely within standard C for hosted environments, open a file read/write, printf() to produce the character string output, rewind to the beginning of the file, and read the string in to the desired destination buffer. Sure it'd be clunky, but conformant.
Depending on how many extensions one was willing to live with, there is even a case in which the operation might be relatively efficient -- if one closed stdout, nmap()'d some memory, took the fd from that [which would be the fd normally used for stdout because of the POSIX rules about using the first available fd], used fdopen() to pull that up to a FILE*, and used printf() to do the desired conversion, then the result could be read back directly from the memory area nmap'd to. Who needs simple standard sprintf() when one can use something complicated, not generally portable, but 3001 ? ;-)
Hmmm. Seems you're about a week late on this response (at least in my
time zone) ;-) ;-)
Cheers,
--ag
[Well, at least it's not "TCP/IP by carrier pigeon"!]
--
Artie Gold -- Austin, Texas http://it-matters.blogspot.com (new post 12/5) http://www.cafepress.com/goldsays
In article <3b************ *@individual.ne t>,
Artie Gold <ar*******@aust in.rr.com> wrote: Walter Roberson wrote:
[...]
Hmmm. Seems you're about a week late on this response (at least in my time zone) ;-) ;-)
[Well, at least it's not "TCP/IP by carrier pigeon"!]
?? According to the message headers, the message that started this
thread was posted at Fri, 08 Apr 2005 12:07:41 EDT, your response was
posted at Fri Apr 08 22:25:33 CDT 2005, and my response was posted at 9
Apr 2005 04:26:55 GMT. I am in CDT myself, as you are, (even though the
posting headers are GMT); I'm pretty much due north of you. CDT is GMT-5,
so my posting was 23:26:55 CDT, or only a hair more than 1 hour after
your posting.
--
"I want to make sure [a user] can't get through ... an online
experience without hitting a Microsoft ad"
-- Steve Ballmer [Microsoft Chief Executive] ro******@ibd.nr c-cnrc.gc.ca (Walter Roberson) writes: In article <3b************ *@individual.ne t>, Artie Gold <ar*******@aust in.rr.com> wrote:Walter Roberson wrote: [...]
Hmmm. Seems you're about a week late on this response (at least in my time zone) ;-) ;-)
[Well, at least it's not "TCP/IP by carrier pigeon"!]
?? According to the message headers, the message that started this thread was posted at Fri, 08 Apr 2005 12:07:41 EDT,
[snip]
Which is one week after April Fool's Day.
--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
On 9 Apr 2005 04:26:55 GMT, Walter Roberson
<ro******@ibd.n rc-cnrc.gc.ca> wrote: printf() is indeed capable of converting integers to character strings -- it just has its own ideas about where the character strings should end up. ;-)
If one cared to go through the bother, one could, completely within standard C for hosted environments, open a file read/write,
Using freopen().
printf() to produce the character string output, rewind to the beginning of the file, and read the string in to the desired destination buffer. Sure it'd be clunky, but conformant.
You forgot to delete the file afterwards. Unfortunately tmpfile() can't
be used to reopen stdout (and in my experience the autodelete
functionality of tmpfile() is one of the things broken in a number of
implementations ).
Depending on how many extensions one was willing to live with, there is even a case in which the operation might be relatively efficient -- if one closed stdout, nmap()'d some memory, took the fd from that [which would be the fd normally used for stdout because of the POSIX rules about using the first available fd], used fdopen() to pull that up to a FILE*,
Which is not guaranteed to be stdout, as I read POSIX (the fd will be
the one used for stdout, but the fp won't).
and used printf() to do the desired conversion, then the result could be read back directly from the memory area nmap'd to. Who needs simple standard sprintf() when one can use something complicated, not generally portable, but 3001 ? ;-)
3001?
Chris C This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 example).
int foo(const char* argv) { return 0; }
int main(int argc, char* argv)
{
|
by: MilanB |
last post by:
Hello
How to convert char to int?
Thanks
|
by: Alper Akcayoz |
last post by:
Hello Esteemed Developpers
I would like to thank you in advance for your sincere responses
I am a fresh Visual C++ .NET Developer. Can you kindly guide me for How to Convert char* to System::String
|
by: Elioth |
last post by:
Hi...
I need to know how to convert Char Array to Byte Array and vice-versa in VB
2K5
Thanks for all help.
Elioth
|
by: Joah Senegal |
last post by:
Hello I need to convert a chat to a string... but I don't know how to do
this. i;ve searched the internet but I've only find some code to convert
char * to string or char to string....
but I just need char to string.
Anyone knows how to do this ?
thanks!!!!
| |
by: simon |
last post by:
I am a fresh Visual C++ .NET Developer. Can you kindly guide me for
How to Convert char to System::String
I am using windows forms and trying to set a text value referencing
the method className() of an object of class HetConvert (my own) this
returns a char - which as you can see from the code below I am trying
to pass to label1->Text - but this expects a String^
any clues anyone
|
by: Rasheed |
last post by:
Hi,
i have a char pointer buffer which will hold the bitmap buffer, So i
need to convert char *buffer as a bitmap.
becuase when i draw on the Dialog using char *buffer. Nothing will be
dispalyed.
So kindly can any body help me how to convert char *buffer to bitmap.
i want the solution in C++
|
by: helios |
last post by:
Hi all,
I'm resolved problem. and I want anybody need me that convert char to array bits
char ConvertChar2ArrayBit(char ch)
{
char Bits;
....
return Bits;
}
for example: A
after converted: 10000010
|
by: mamul |
last post by:
Hi please some one can help me. how to convert char * to string?
i have take char *argv from command line and want to pass to a function as string object(string str)
i want to first convert argv to string object of type str, then pass to function().
please help me how to convert this
|
by: DaveRook |
last post by:
Hi
I've had a few error messages with this I don't understand why. It works fine in a Windows Form, but now moving it to a website, it's not working. I don't have the option to count the lines as I did with Windows Forms so I assume the best way is to use the split method. However, the split method only returns Character Arrays, and I want a string, so am calling the split from the Text.RegularExpression namespace.
I am trying to split...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |