Skip to contentSkip to conversation

Type conversion

DISCUSSION Adam Luchjenbroers 5 participants 6 messages Jun 28, 2002 – Jun 29, 2002

lore
Share & tools
lore
#0 lore raw

What are the C/C++ functions for converting between variable types.

ATM I need to be able to convert a long to an int. But I thought it would be good to find out about the others while I'm here.

#1 lore raw
Quoted 4 lines · Adam Luchjenbroers

What are the C/C++ functions for converting between variable types.

ATM I need to be able to convert a long to an int. But I thought it would be good to find out about the others while I'm here.

Conversion between numeric types is handled by "casts" (which are a language feature) rather than explicit functions, i.e.

	int i;
	long l;
	...
	i = (int) l;

If you weren't aware of type casts, you probably need to get a book on C.

You can't realistically learn a language from a combination of trial-and-error and asking questions on mailing lists. Primarily because, for many of the things which you need to learn, you won't realise that you need to learn them until you've learnt them.

Signature · 1 line
Glynn Clements <[email protected]>
#2 lore raw
Quoted 3 lines

If you weren't aware of type casts, you probably need to get a book on C.

Is there a good book you could recommend.

Quoted 4 lines

You can't realistically learn a language from a combination of trial-and-error and asking questions on mailing lists. Primarily because, for many of the things which you need to learn, you won't realise that you need to learn them until you've learnt them.

I've learned alot from various projects where I've worked with code already given to me and I've absorbed the techniques I've seen used. That said, there would still be many techniques I don't know.

#3 lore raw
Quoted 5 lines · Adam Luchjenbroers
Quoted 2 lines

 If you weren't aware of type casts, you probably need to get a book on C.

Is there a good book you could recommend.

The C Programming Language (or some other name)
by Brian W. Kernighan and Dennis M. Ritchie

C++ (I don;t know the name)
by Bjarne Stoustrup

Quoted 8 lines
Quoted 4 lines

 You can't realistically learn a language from a combination of trial-and-error and asking questions on mailing lists. Primarily because, for many of the things which you need to learn, you won't realise that you need to learn them until you've learnt them.

I've learned alot from various projects where I've worked with code already given to me and I've absorbed the techniques I've seen used. That said, there would still be many techniques I don't know.

Bye,
Suriya Narayanan M S

Signature · 10 lines
Guru Brahma Gurur Vishnu
Gurur Dhevo Maheshwaraha
Gurur Saakshaath Parabramha
Thasmai Shree Gurave Namaha

Public key at www.keyserver.net
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw
In reply to Adam Luchjenbroers
Quoted 5 lines · Adam Luchjenbroers
Quoted 3 lines

If you weren't aware of type casts, you probably need to get a book on C.

Is there a good book you could recommend.

K&R is pretty much the defacto standard for learning the language:
http://www.amazon.com/exec/obidos/ASIN/0131103628/qid=1025280640/sr=8-1/ref=sr_8_1/102-5246061-6069731

If you want a UNIX programming book in C:
http://www.amazon.com/exec/obidos/ASIN/0201563177/qid=1025281187/sr=1-1/ref=sr_1_1/102-5246061-6069731

Quoted 8 lines
Quoted 4 lines

You can't realistically learn a language from a combination of trial-and-error and asking questions on mailing lists. Primarily because, for many of the things which you need to learn, you won't realise that you need to learn them until you've learnt them.

I've learned alot from various projects where I've worked with code already given to me and I've absorbed the techniques I've seen used. That said, there would still be many techniques I don't know.

Casting is a very fundamental concept. :) Also, learning things in the wrong order could hurt you later. Read a book; it's a good thing.

Quoted 4 lines

-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
In reply to Suriya Narayanan M S
Quoted 12 lines · Adam Luchjenbroers
Quoted 5 lines
Quoted 2 lines

If you weren't aware of type casts, you probably need to get a book on C.

Is there a good book you could recommend.

The C Programming Language (or some other name)
by Brian W. Kernighan and Dennis M. Ritchie

C++ (I don;t know the name)
by Bjarne Stoustrup

(...)

The C++ Programming Language
by Bjarne Stroustrup

flv
http://h4.locked.org