473,796 Members | 2,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

function conversion

Hi,

I know there are in stdlib.h many functions to perform conversion from
string to int, double ecc.
but I don't understand if there are some standards function to perform
conversion from
int, double ecc to string

Thanks.

Jul 2 '07 #1
19 1556
xdevel wrote:
Hi,

I know there are in stdlib.h many functions to perform conversion from
string to int, double ecc.
but I don't understand if there are some standards function to perform
conversion from
int, double ecc to string
I would use sprintf (or snprintf) from stdio.h
>
Thanks.

--
Pietro Cerutti

PGP Public Key:
http://gahr.ch/pgp
Jul 2 '07 #2
On 2 Lug, 15:23, Pietro Cerutti <g...@gahr.chwr ote:
xdevel wrote:
Hi,
I know there are in stdlib.h many functions to perform conversion from
string to int, double ecc.
but I don't understand if there are some standards function to perform
conversion from
int, double ecc to string

I would use sprintf (or snprintf) from stdio.h
Thanks.

--
Pietro Cerutti

PGP Public Key:http://gahr.ch/pgp
Yes, but I wish to know if there are standard "one-to-one" functions.
I read that i.e. itoa is not!

Jul 2 '07 #3

"xdevel" <xd********@gma il.comwrote in message
news:11******** *************@g 4g2000hsf.googl egroups.com...
Hi,

I know there are in stdlib.h many functions to perform conversion from
string to int, double ecc.
but I don't understand if there are some standards function to perform
conversion from
int, double ecc to string
'sprintf()' works like 'printf()', except the output
is to a string instead of stdout.

(Be careful to ensure that your strings are large
enough to hold the output).

-Mike
Jul 2 '07 #4
Mike Wahler wrote:
"xdevel" <xd********@gma il.comwrote in message
news:11******** *************@g 4g2000hsf.googl egroups.com...
>Hi,

I know there are in stdlib.h many functions to perform conversion from
string to int, double ecc.
but I don't understand if there are some standards function to perform
conversion from
int, double ecc to string

'sprintf()' works like 'printf()', except the output
is to a string instead of stdout.

(Be careful to ensure that your strings are large
enough to hold the output).
Or use snprintf() and set the limit yourself.
>
-Mike


--
Pietro Cerutti

PGP Public Key:
http://gahr.ch/pgp
Jul 2 '07 #5
xdevel <xd********@gma il.comwrites:
On 2 Lug, 15:23, Pietro Cerutti <g...@gahr.chwr ote:
>xdevel wrote:
I know there are in stdlib.h many functions to perform conversion from
string to int, double ecc.
but I don't understand if there are some standards function to perform
conversion from
int, double ecc to string

I would use sprintf (or snprintf) from stdio.h

Yes, but I wish to know if there are standard "one-to-one" functions.
I read that i.e. itoa is not!
No.

You can see all the functions in the standard C library by reading the
standard; search for "n1124.pdf" to see the latest draft.

(Please don't quote signatures; trim quoted material to what's
necessary for your response to make sense.)

--
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."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 2 '07 #6
Pietro Cerutti <ga**@gahr.chwr ites:
Mike Wahler wrote:
>"xdevel" <xd********@gma il.comwrote in message
news:11******* **************@ g4g2000hsf.goog legroups.com...
>>I know there are in stdlib.h many functions to perform conversion from
string to int, double ecc.
but I don't understand if there are some standards function to perform
conversion from
int, double ecc to string

'sprintf()' works like 'printf()', except the output
is to a string instead of stdout.

(Be careful to ensure that your strings are large
enough to hold the output).

Or use snprintf() and set the limit yourself.
If your implementation provides snprintf(). That function was added
in C99; many non-C99 implementations provide it as an extension, but
not all do.

--
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."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 2 '07 #7
Keith Thompson wrote:
Pietro Cerutti <ga**@gahr.chwr ites:
>Mike Wahler wrote:
>>"xdevel" <xd********@gma il.comwrote in message
news:11****** *************** @g4g2000hsf.goo glegroups.com.. .
I know there are in stdlib.h many functions to perform conversion from
string to int, double ecc.
but I don't understand if there are some standards function to perform
conversion from
int, double ecc to string
'sprintf()' works like 'printf()', except the output
is to a string instead of stdout.

(Be careful to ensure that your strings are large
enough to hold the output).
Or use snprintf() and set the limit yourself.

If your implementation provides snprintf(). That function was added
in C99; many non-C99 implementations provide it as an extension, but
not all do.
Uh, I wasn't aware of the fact that snprintf (and also vsnprintf) were
added only in C99.

Tnx for pointing it out!
--
Pietro Cerutti

PGP Public Key:
http://gahr.ch/pgp
Jul 2 '07 #8
Pietro Cerutti wrote, On 02/07/07 18:05:
Keith Thompson wrote:
>Pietro Cerutti <ga**@gahr.chwr ites:
<snip>
>>Or use snprintf() and set the limit yourself.
If your implementation provides snprintf(). That function was added
in C99; many non-C99 implementations provide it as an extension, but
not all do.

Uh, I wasn't aware of the fact that snprintf (and also vsnprintf) were
added only in C99.
You also need to be aware that not all C89 implementations that provide
it as an extension provide the same semantics as C99 requires. IIRC the
_snprintf function MS provide has different sementaics (this is legal as
it starts with an _ and MS do not claim C99), for example.
--
Flash Gordon
Jul 2 '07 #9
On 2007-07-02, Flash Gordon <sp**@flash-gordon.me.ukwro te:
Pietro Cerutti wrote, On 02/07/07 18:05:
>Keith Thompson wrote:
>>Pietro Cerutti <ga**@gahr.chwr ites:

<snip>
>>>Or use snprintf() and set the limit yourself.
If your implementation provides snprintf(). That function was added
in C99; many non-C99 implementations provide it as an extension, but
not all do.

Uh, I wasn't aware of the fact that snprintf (and also vsnprintf) were
added only in C99.

You also need to be aware that not all C89 implementations that provide
it as an extension provide the same semantics as C99 requires. IIRC the
_snprintf function MS provide has different sementaics (this is legal as
it starts with an _ and MS do not claim C99), for example.
At first when I read this I was surprised that this was legal
since I thought that identifiers starting with an underscore
are reserved. Then when I checked the standard I understood that
it is reserved for implementations , which it is in this case.

I just want to check if I've understood this correct:
is it true, that all the reserved identifiers in the standard
are reserved for use only by the implementations ?
That is, if I'm writing and implementation of the standard libary
I am permitted to define new functions starting with an underscore,
but _not_ if I'm making some library that is not the standard lib?

--
Michael Brennan

Jul 2 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
2112
by: Dave | last post by:
Hello all, Can anybody help with the problem below? I'm trying to define a conversion function that converts objects to function pointers and am getting a compile error on the line indicated below. The compiler interprets this is a function returning a function, which, of course is illegal... What is the correct syntax to accomplish this? Thanks, Dave
3
2393
by: Ken | last post by:
hello, I would to know if it is possible to call an object in a function within a class. Meaning , In a class, A function X calling onto a function Y, and function Y we want one of the two calculation ( eg seconds , out of seconds and minutes) thanks , Ken
1
3983
by: Bryan Parkoff | last post by:
I know how to write "Pointer to Function" inside struct or class without using static, but I have decided to add static to all functions inside struct or class because I want member functions to be bound inside struct or class to become global functions. It makes easier for me to use "struct.memberfunction()" instead of "globalfunction()" when I have to use dot between struct and member function rather than global function. I do not have...
89
6538
by: Sweety | last post by:
hi, Is main function address is 657. its show in all compiler. try it & say why? bye,
21
1798
by: Stephen Biggs | last post by:
Given this code: void f(void){} int main(void){return (int)f+5;} Is there anything wrong with this in terms of the standards? Is this legal C code? One compiler I'm working with compiles this quietly, even with the most stringent and pedantic ANSI and warning levels, but generates code that only loads the address of "f" and fails to make the addition before returning a value from "main".
27
2492
by: Marlene Stebbins | last post by:
I am experimenting with function pointers. Unfortunately, my C book has nothing on function pointers as function parameters. I want to pass a pointer to ff() to f() with the result that f() prints the return value of ff(). The code below seems to work, but I would appreciate your comments. Have I got it right? Does the function name "decay" to a pointer? #include <stdio.h> /* declares a function which takes an argument that is a...
57
5680
by: Robert Seacord | last post by:
i am trying to print the address of a function without getting a compiler warning (i am compiling with gcc with alot of flags). if i try this: printf("%p", f); i get: warning: format %p expects type 'void *; but argument 2 has type 'void
32
3535
by: David Mark | last post by:
I've got a collection of functions that accept a function or object (paired with a method name) as a callback. For the longest time I have relied on this test. (typeof cb == 'function') This should work as well, but I am not sure how well it degrades in older browsers. I think there are issues with functions created in another context (eg frame) as well.
10
1895
by: colin | last post by:
Hi, I profile my code and find its spending a lot of time doing implicit conversions from similar structures. the conversions are mainly things like this class Point { implicit conversion to vector3; //this conversion just returns positon Vector3 position;
4
3381
by: abendstund | last post by:
Hi, I have the following code and trouble with ambiguity due to operator overloading.. The code is also at http://paste.nn-d.de/441 snip>>
0
9685
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, 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...
0
9531
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10237
jinu1996
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...
1
10187
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,...
0
10018
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6795
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();...
1
4120
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3735
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.