473,890 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Looking for a C textbook with emphasis on data types

I am supposed to teach an introductory C course with an unusual slant,
and have trouble finding an appropriate textbook. The course will begin
traditionally enough with variables, loops, conditionals, structures,
pointers and fopen/fclose. Beyond that, however, every course and
textbook I had seen is heavy on data *structures*, and touches on other
topics lightly if at all. Whereas I need to stress data *types*,
converting them one into the other, and bit manipulation. By the end of
the course I do not care if my students know what a linked list is, let
alone a binary tree, but they must have good understanding of ASCII,
binary and hexadecimal. For example, it must clear to them why number
353 is actually stored as 0x01 0x61 if it's and INT, but 0x33 0x35 0x33
if it's a CHAR*. Or why converting a numeric CHAR into an INT involves
subtracting 48 -- and not 30, as previous example might suggest.

Is there a textbook with such emphasis on data types, bits, and
hexadecimal, or am I doomed to writing my own?

Jul 14 '06 #1
20 1906
il***@rcn.com said:

<snip>
By the end of
the course I do not care if my students know what a linked list is, let
alone a binary tree, but they must have good understanding of ASCII,
Why? That has nothing to do with C.
binary and hexadecimal. For example, it must clear to them why number
353 is actually stored as 0x01 0x61 if it's and INT,
There is no INT type in C. 353 might be stored as 0x0161, but it might be
stored as 0x6101, 0x00006101 (i.e. in 4 octets), or as 0x61010000 (little
endian, four octets to the int), or in any of a zillion other ways.
but 0x33 0x35 0x33 if it's a CHAR*.
C has no CHAR type. To store the characters '3', '5', and '3', you need
three bytes of storage. A pointer to the first of these characters will
/not/ have the value 0x333533 (unless by some astounding coincidence).
Or why converting a numeric CHAR into an INT involves
subtracting 48 --
It doesn't. If you mean turning '4' into 4 or '6' into 6, it involves
subtracting '0', not 48.
and not 30, as previous example might suggest.

Is there a textbook with such emphasis on data types, bits, and
hexadecimal, or am I doomed to writing my own?
Oh my word. Please, please, please don't write your own, until you
understand what you're talking about.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jul 14 '06 #2

il***@rcn.com wrote:
I am supposed to teach an introductory C course with an unusual slant,
and have trouble finding an appropriate textbook. The course will begin
traditionally enough with variables, loops, conditionals, structures,
pointers and fopen/fclose. Beyond that, however, every course and
textbook I had seen is heavy on data *structures*, and touches on other
topics lightly if at all.
Are you talking about any C book or some data structures book ?
>Whereas I need to stress data *types*,
Is it required ?
converting them one into the other, and bit manipulation. By the end of
the course I do not care if my students know what a linked list is, let
alone a binary tree, but they must have good understanding of ASCII,
binary and hexadecimal.
Which of these is 'C' ?
>For example, it must clear to them why number
353 is actually stored as 0x01 0x61 if it's and INT,
Is it ?? its NEWS. What if you are using a machine with little endian
byte ordering ?
>but 0x33 0x35 0x33
if it's a CHAR*.
How can number 353 be char * ??
>Or why converting a numeric CHAR into an INT involves
subtracting 48 -- and not 30, as previous example might suggest.
Who told you to subtract 30 ?
You have to subtract ' 0'. And you would have missed ' 0x' while you
were reading.
It should have been 0x30.
Is there a textbook with such emphasis on data types, bits, and
hexadecimal, or am I doomed to writing my own?
Ooops...
No please,,, for god's sake.

Go and read " the holy book" , The C programming language, by K & R.

Jul 14 '06 #3
"arun" writes:
>Is there a textbook with such emphasis on data types, bits, and
hexadecimal, or am I doomed to writing my own?

Ooops...
No please,,, for god's sake.
Think of the children!!!
Jul 14 '06 #4
but 0x33 0x35 0x33
if it's a CHAR*.

How can number 353 be char * ??
If it's a character string "353"

Jul 14 '06 #5
Or why converting a numeric CHAR into an INT involves
subtracting 48 -- and not 30, as previous example might suggest.

Who told you to subtract 30 ?
You have to subtract ' 0'.
48 is decimal value of '0'. In hexadecimal it is 0x30
And you would have missed ' 0x' while you
were reading.
It should have been 0x30.
I know that. I was bringing up an example of a mistake someone
unfamiliar with hexadecimal may make.

Jul 14 '06 #6
il***@rcn.com said:
>
>but 0x33 0x35 0x33
if it's a CHAR*.

How can number 353 be char * ??

If it's a character string "353"
Then it isn't a CHAR *. It's a string literal - a static array of four char.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jul 14 '06 #7
il***@rcn.com said:
>
>Or why converting a numeric CHAR into an INT involves
subtracting 48 -- and not 30, as previous example might suggest.

Who told you to subtract 30 ?
You have to subtract ' 0'.

48 is decimal value of '0'.
The C Standard does not guarantee this, and it is certainly not true on some
systems where C is used.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jul 14 '06 #8
On 2006-07-14, il***@rcn.com <il***@rcn.comw rote:
>
>Or why converting a numeric CHAR into an INT involves
subtracting 48 -- and not 30, as previous example might suggest.

Who told you to subtract 30 ?
You have to subtract ' 0'.

48 is decimal value of '0'. In hexadecimal it is 0x30
The size of a monitor is 17 inches. In hexadecimal it is 0x11.
Weird how it looks to others when you assume that everyone is using your
environment, huh.
>And you would have missed ' 0x' while you
were reading.
It should have been 0x30.

I know that. I was bringing up an example of a mistake someone
unfamiliar with hexadecimal may make.
If you are so unfamiliar with hexadecimal that you don't know what 0x
means, you shouldn't be learning programming languages, and if your
students do not know what 0x means, you shouldn't teach them anything
else before that.

--
Andrew Poelstra <http://www.wpsoftware. net/projects/>
To email me, use "apoelstra" at the above domain.
"You people hate mathematics." -- James Harris
Jul 14 '06 #9
il***@rcn.com wrote:
>Or why converting a numeric CHAR into an INT involves
subtracting 48 -- and not 30, as previous example might suggest.
Who told you to subtract 30 ?
You have to subtract ' 0'.

48 is decimal value of '0'. In hexadecimal it is 0x30
Oddly enough, the hexadecimal value of '0' on every one of my systems
is F0.

I guess I should enroll in your class so I can learn C properly.

(gosh, subtracting 48, wow, I am so glad my boss never gave me that
assignment because I foolishly would have subtracted 240. Maybe that's
why I was never given the assignment to convert a numeric CHAR into an
INT.)

Jul 14 '06 #10

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

Similar topics

22
2298
by: Martin MOKREJ© | last post by:
Hi, I'm looking for some easy way to do something like include in c or PHP. Imagine I would like to have: cat somefile.py a = 222 b = 111 c = 9
0
515
by: JimC | last post by:
Database design is well covered in undergrad CS. But does anyone know of a textbook that deals with the design of database servers (and probably touches on databases themselves), and perhaps deals with interpreting SQL inquiries? The motivation for this is that I wish to write a database server for a proprietary operating system (it resembles POSIX, but is not completely compliant) for an embedded processor system that exchanges...
8
1683
by: Alan J. Flavell | last post by:
OK, I guess I'm about ready to expose this page for public discussion: http://ppewww.ph.gla.ac.uk/~flavell/charset/i18n-weft.html Please concentrate on the content. I'm well aware that my old stylesheet is in need of modernisation, but this isn't the moment to get sidetracked by that. If anyone is previewing IE7 (which I am not), they might care to comment on whether anything has been done to address the problem in IE(<=6) where...
6
1378
by: bambooforest | last post by:
Hi all, I'm from a Linguistics background and am new(er) to programming. Could someone recommend a book or resource that teaches programming aspects with Python? Python I hear is a very appropriate language for handling text and language processing. I'm searching for a resource that examines programming from a case study like perspective. Such as, you're faced with problem of type X - and here's how you should look at it to break it...
13
2665
by: Grant Edwards | last post by:
I need to interpolate an irregularly spaced set of sampled points: Given a set of x,y,z points, I need to interpolate z values for a much finer x,y grid. I tried using the scipy sandbox delaunay module, but the interpolators don't work: the natural neighbor interpolator produces a surface with "holes" in it: the interpolator returns NaNs for no reason for certain regions within the convex hull (the convex hull looks right, and the input...
63
2713
by: time.swift | last post by:
Coming from a C++ / C# background, the lack of emphasis on private data seems weird to me. I've often found wrapping private data useful to prevent bugs and enforce error checking.. It appears to me (perhaps wrongly) that Python prefers to leave class data public. What is the logic behind that choice? Thanks any insight.
0
2002
by: AMDRIT | last post by:
I am looking for better concrete examples, as I am a bit dense, on design patterns that facilitate my goals. I have been out to the code project, planet source code, and microsoft's patterns and practices site and it just isn't sinking in all that clearly to me. Currently we have code in production and it all works well, however it is not the way we want it. We know that we can implement a better design plan to improve performance,...
0
9819
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
11222
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10811
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...
0
10461
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...
1
8015
isladogs
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...
0
5846
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...
0
6041
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4674
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
4270
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.