:: Re: [DNG] Learning C (books)
トップ ページ
このメッセージを削除
このメッセージに返信
著者: dvalin
日付:  
To: dng
題目: Re: [DNG] Learning C (books)
On 28.09.24 17:04, R A Montante, Ph.D. via Dng wrote:

>


> Different strokes for different folks.  I loved learning C from K&R.


As mentioned upthread, I wouldn't use K&R syntax this millenium. While I

still have the old K&R edition, their (was it Addison Wesley?) ANSI

update was also published last century, IIRC.

And if, like me, you can't immediately lay hands on either version of

the book, then there's manpages. Since it's the first thing which came

to mind, I've just typed:

$ man strcpy

giving the needed #include and function prototype, then instructional

bumpf and alternatives. That can often be just enough to get you over a

hump. The entire "man 3 ... " manpages section is C stuff.

And "man -k strcpy"  gives (here, anyway):

strcpy (3)           - copy a string

strcpy (3avr)        - (unknown subject)

strcpy_P (3avr)      - (unknown subject)

strcpy_PF (3avr)     - (unknown subject)

and "man strcpy_P" gives an overwhelming surfeit of bumpf on doing strcpy from program memory (Flash ROM) on the Harvard architecture AVR chips.

There are also "info" pages on some things. I don't have info installed,

but long ago collected a couple of info pages on gas, and search them

using vim, as that's more effective at finding stuff. Admittedly, a few

obscure bits and pieces are undocumented, but that's where these mailing

lists come in. (In embedded programming, a custom linker script can be

very handy. If in trouble, just yell out. Gas macros, likewise.)

> Every time I hit a problem, a careful reading of the relevant parts


> always explained it.  But that was me (and in a very different era),


> and as I am currently teaching C I know that many of my students need


> more structural support in learning I did.  I've just starting using


> an online textbook instead of only my own notes, and most of them seem


> to like having something they can refer to when they're on their own.


Those of us oldies still plugging away at a bit of coding are likely

autodidacts, capable of learning in a straightjacket, but the herd

doesn't share that investigative curiosity, that need to figure it out,

'cos there's gotta be a solution hiding in this mess somewhere.

A couple of days ago, one of my gas macros:

led red on        ; Handles: red/green/orange & on/off/toggle

; via I/O PORTC pins 4,5 & a bicolour LED.

generated the correct assembler for green/orange, but not for "red".

The info page admits that macro handling of ':' on local labels can fail

due to confusion of special meaning of same, but didn't mention that 'r'

can similarly misfire, perhaps due to an initial 'r' most often being

used for register identifiers, e.g. "r15". Changing the colours to

Red/Green/Orange fixed it.

I've now added that to my 460 pages of notes, accumulated over decades.

(They're needed because I eschew GUIs with a vengeance, making retention

of useful/essential command/parameter combinations more than merely

useful.)

Erik