Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-17-2005, 12:28 AM   #1
Senior Member
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,197

Rep: Reputation: 45
type cast

Hi... whats the easiest way for converting an integer, double to a string?
Do u have some good articles for type casting?

I have written a simple function for writing things to a file... the problem is that the function take only two arguments a string to write in the file and the file path of the file... After using my function i have noticed that isnt so easy to store integers and results from other functions so i need your help to modify my function...
Any good suggestions?
Thxx a lot
Old 07-17-2005, 12:32 AM   #2
Registered: Sep 2004
Location: western massachusetts
Distribution: fedora core 3, Suse 10
Posts: 877

Rep: Reputation: 35
what language are you writing in?
Old 07-17-2005, 04:58 AM   #3
Senior Member
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Type casting and converting numbers to strings are unrelated. Check out this site for what you are looking for:

These work for C and C++, but in C++ you need to #include cstdlib instead of stdlib.h. Also, some C++ compilers put some/all/none of these functions in namespace std, so watch out for that.

As far as casting, in C all you need to do is put the type to be casted to in parens:
int Num = (int) 'a';

That is frowned upon in C++, however. Take a look here for casting in C++:

The C-cast is equivalent to reinterpret_cast when used in C++, and can be dangerous when dealing with classes. It does serve useful for turning objects into raw data however (unsigned char).


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
can you cast arrays? (c++) nadroj Programming 7 10-13-2005 01:34 AM
type cast from int to QString spoody_goon Programming 2 05-24-2005 06:14 AM
pointer from integer without a cast bcf2 Programming 7 12-30-2004 02:04 PM
what does a cast in c++ actually do? markhod Programming 2 12-23-2004 09:01 AM
Question on type cast cxel91a Programming 2 12-05-2003 09:13 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:54 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration