473,386 Members | 1,962 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

i want to convert long integer to string

I am working under a Linux environment, and I want to convert a
long int into a string. It looks doesnt't have a function such ltoa,itoa
on stdlib.
How Can I do that?
I tried to work with double numbers, and convert them using fcvt
function included into stdlib, but after compiled, when I run the
job, I got an error:
Segmentation Error (core dumped).
I don't know what to do!
seema
Nov 14 '05 #1
3 37453
seema wrote:
I am working under a Linux environment, and I want to convert a
long int into a string. It looks doesnt't have a function such ltoa,itoa
on stdlib.
How Can I do that?
I tried to work with double numbers, and convert them using fcvt
function included into stdlib, but after compiled, when I run the
job, I got an error:
Segmentation Error (core dumped).
I don't know what to do!
seema


char tmp[255];
long foo;

sprintf(tmp, "%d", foo);

See the printf manpage for appropriate conversion rules.

Greetings, Chris

--
Christian Staudenmayer
University of Ulm, Germany
cs****@gmail.com
Nov 14 '05 #2
Christian Staudenmayer <cs****@gmail.com> wrote:
seema wrote:
I am working under a Linux environment, and I want to convert a
long int into a string. It looks doesnt't have a function such ltoa,itoa
on stdlib.
How Can I do that?
char tmp[255];
long foo; sprintf(tmp, "%d", foo);


I guess you meant to write

sprintf(tmp, "%ld", foo);
Regards, Jens
--
\ Jens Thoms Toerring ___ Je***********@physik.fu-berlin.de
\__________________________ http://www.toerring.de
Nov 14 '05 #3
Je***********@physik.fu-berlin.de wrote:
Christian Staudenmayer <cs****@gmail.com> wrote:
seema wrote:
I am working under a Linux environment, and I want to convert a
long int into a string. It looks doesnt't have a function such ltoa,itoa
on stdlib.
How Can I do that?


char tmp[255];
long foo;


sprintf(tmp, "%d", foo);

I guess you meant to write

sprintf(tmp, "%ld", foo);
Regards, Jens


Oops.

--
Christian Staudenmayer
University of Ulm, Germany
cs****@gmail.com
Nov 14 '05 #4

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

Similar topics

5
by: Sam Smith | last post by:
Hi, is there a function or a "well-known" algorithm which converts a number of random length represented as an array of bytes to its binary format? For example: a 16 byte long array:...
17
by: MLH | last post by:
After running the following code snippet... MyURL = "http://tycho.usno.navy.mil/what.html" msXML.Open "GET", MyURL, False msXML.send I would like to execute code to perform essentially what...
4
by: pcPirate | last post by:
Hi, Can anyone help me to convert the following VB6 code into C#??? Declare Function SQLSetConnectOption Lib "ODBC32.DLL" (ByVal hDbc As Long, ByVal iOption As Integer, ByVal lValue As Long)...
2
by: Mel WEaver | last post by:
Hello, I have the following delphi structure for a binary file. I'm looking for idea how to read this file. Mel type TMenuDataStruct = packed record exename : string;
17
by: David Scemama | last post by:
Hi, I'm writing a program using VB.NET that needs to communicate with a DOS Pascal program than cannot be modified. The communication channel is through some file databases, and I have a huge...
15
by: Tanzim Saqib | last post by:
I've been trying to learn VB.NET. I know VB6. I can not convert the following VB6 code segment to VB.NET In VB 6: ' In a module starts here: Public Declare Function SetTimer Lib "user32"...
14
by: Michael Barrido | last post by:
I have this for example: Dim iSeconds as int32 = 3600 '3600 seconds is one hour How do i convert it to "01:00:00" ? Please help. Thanks in advance!
43
by: Steven T. Hatton | last post by:
http://public.research.att.com/~bs/bs_faq2.html#int-to-string Is there no C library function that will take an int and convert it to its ascii representation? The example Bjarne shows in his faq...
7
by: wenmang | last post by:
what is format for sprintf to convert long long integer (64 bits) to string?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...

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.