Path: news.demon.co.uk!dispatch.news.demon.net!demon!news-lond.gsl.net!news.gsl.net!news-peer.gsl.net!news.gsl.net!howland.erols.net!worldnet.att.net!newsxfer2.itd.umich.edu!uunet!in3.uu.net!204.245.3.50!news.primenet.com!usr10.primenet.com!kellis From: Katherine L Ellis Newsgroups: comp.sys.atari.programmer Subject: Re: C tutorial begins January 1st Date: 30 Dec 1996 05:44:02 -0700 Organization: Primenet Services for the Internet Lines: 10 Message-ID: References: <19961229210900.QAA18421@ladder01.news.aol.com> X-Posted-By: kellis@206.165.5.110 (kellis) To: RDupuy5596 In-Reply-To: <19961229210900.QAA18421@ladder01.news.aol.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII ohhh Great... PLease do it, and do it from the very start. My problem is how to start and understand the basic, even including how to compile.. Bye.. ________________________________________________________________________________ Email:Kellis@primenet.com Web http://www.primenet.com/~kellis/ ________________________________________________________________________________ . Path: news.demon.co.uk!dispatch.news.demon.net!demon!news-lond.gsl.net!news.gsl.net!news-stkh.gsl.net!news.gsl.net!sn.no!online.no!nntp-oslo.UNINETT.no!nntp-trd.UNINETT.no!newsfeed.sunet.se!news99.sunet.se!news.chalmers.se!dtek.chalmers.se!d8klojo From: d8klojo@dtek.chalmers.se (Johan Klockars) Newsgroups: comp.sys.atari.programmer Subject: Re: C tutorial begins January 1st Date: 2 Jan 1997 01:57:10 GMT Organization: Chalmers University of Technology Lines: 28 Message-ID: <5af4lm$41n@nyheter.chalmers.se> References: <19961229210900.QAA18421@ladder01.news.aol.com> NNTP-Posting-Host: stettin.dtek.chalmers.se In article <19961229210900.QAA18421@ladder01.news.aol.com>, RDupuy5596 wrote: >Here is your chance to learn C! > >Starting January 1st I will be posting lessons on about a biweekly basis >on the C programming language. I will be concentrating on the basics of Great idea! I hope you don't mind if other people jump in and clarify, explain etc. ;-) >I will be using Laser C, but I don't think there will be many compiler >specific issues. Nevertheless, I will help anyone who so desires, locate >a copy of Laser C... I thought that company went out of business more than five years ago. Sozobon C (various versions) is freely available on the Internet and can be used on a 1 Mbyte machine with floppies IIRC. The very best Atari compiler (not counting compile speed or IDE), GCC, is also free, but you need 4 Mbyte and a harddrive to use that. G++ is the C++ version of the same compiler (only C++ available for the Atari). -- Chalmers University | Why are these | e-mail: rand@cd.chalmers.se of Technology | .signatures | johan@rand.thn.htu.se | so hard to do | WWW/ftp: rand.thn.htu.se Gothenburg, Sweden | well? | (MGIFv5, QLem, BAD MOOD) . Path: news.demon.co.uk!dispatch.news.demon.net!demon!news.sprintlink.net!news-peer.sprintlink.net!news.bbnplanet.com!cpk-news-hub1.bbnplanet.com!portc02.blue.aol.com!audrey01.news.aol.com!not-for-mail From: rdupuy5596@aol.com (RDupuy5596) Newsgroups: comp.sys.atari.programmer Subject: Re: C tutorial begins January 1st Date: 4 Jan 1997 22:43:50 GMT Organization: AOL http://www.aol.com Lines: 13 Message-ID: <19970104224200.RAA01727@ladder01.news.aol.com> References: <5af4lm$41n@nyheter.chalmers.se> NNTP-Posting-Host: ladder01.news.aol.com X-Admin: news@aol.com Yes, feel free to clarify, Yes, Megamax is out of business. I am not current on all of the Atari issues, so please jump in when I stick a foot in my mouth. I thought most compilers would come from a company that has since abandoned the Atari platform since Atari has abandoned the Atari platform... If you find a company that has active support, I would choose it over Megamax anyday. Thanks for your help. . Path: news.demon.co.uk!dispatch.news.demon.net!demon!news.sprintlink.net!news-peer.sprintlink.net!howland.erols.net!surfnet.nl!newsfeed.sunet.se!news01.sunet.se!sunic!mn6.swip.net!plug.news.pipex.net!pipex!hole.news.pipex.net!pipex!bowl.news.pipex.net!pi ex!news.ukpats.org.uk!lade.news.pipex.net!pipex!dish.news.pipex.net!pipex!news.airtime.co.uk!usenet From: stosser@airtime.co.uk (Tony Greenwood) Newsgroups: comp.sys.atari.programmer Subject: Re: C Tutorial - Help Date: Tue, 31 Dec 1996 19:53:43 GMT Organization: STOSSER Software Lines: 22 Message-ID: <32c96e8f.25996581@news.airtime.co.uk> References: <852096106_OASIS_@stainsby.demon.co.uk> <19961231193500.OAA18218@ladder01.news.aol.com> Reply-To: stosser@airtime.co.uk NNTP-Posting-Host: stosser.airtime.co.uk X-Newsreader: Forte Agent .99e/32.201 On 31 Dec 1996 19:36:36 GMT, rdupuy5596@aol.com (RDupuy5596) wrote: >programs for other environments. I believe there is a version of BASIC >called STOS available for free download. >(www.airtime.co.uk/users/stosser) Sorry but STOS is commercial, and not available for download from anywhere, never has been from my page and never will be, However there is a STOS file site for support programs and this I presume is where the missunderstaning occured, an honest mistake by the original poster Looking forward to this tutorial myself, but buggered if I can get hold of a C compiler ??? Cheers..............!ynoT Tony Greenwood ( STOSSER Software ) stosser@airtime.co.uk irc #ATARI http://www.airtime.co.uk/users/stosser Keeper of the STOS.FAQ and Joint Maintainer of the STOS FTP Site Path: news.demon.co.uk!dispatch.news.demon.net!demon!news.bbnplanet.com!cpk-news-hub1.bbnplanet.com!feed1.news.erols.com!howland.erols.net!cliffs.rs.itd.umich.edu!portc01.blue.aol.com!spamz.news.aol.com!audrey01.news.aol.com!not-for-mail From: rdupuy5596@aol.com (RDupuy5596) Newsgroups: comp.sys.atari.programmer Subject: Re: C Tutorial - Help Date: 31 Dec 1996 23:24:44 GMT Organization: AOL http://www.aol.com Lines: 18 Message-ID: <19961231232300.SAA24009@ladder01.news.aol.com> References: <32c96e8f.25996581@news.airtime.co.uk> NNTP-Posting-Host: ladder01.news.aol.com X-Admin: news@aol.com You wrote: >> Sorry but STOS is commercial, and not available for download from anywhere, never has been from my page and never will be, However there is a STOS file site for support programs and this I presume is where the missunderstaning occured, an honest mistake by the original poster Now I'm writing: Yes, that was an honest mistake on my part! Sorry...was there ever a free version of basic for the Atari or am I going to have to change my introduction? Anyway everyone should check out Tony's page because it has a bunch of great stuff on it!!! As far as C compilers go, it looks like everyone intends to use a different compiler. I am going to use Megamax Laser C... . Path: news.demon.co.uk!dispatch.news.demon.net!demon!news.bbnplanet.com!cpk-news-hub1.bbnplanet.com!news.sprintlink.net!news-peer.sprintlink.net!howland.erols.net!news.nacamar.de!news.apfel.de!fu-berlin.de!irz401!orion.sax.de!alkor.sax.de!haase Newsgroups: comp.sys.atari.programmer Subject: Re: C Tutorial - Help Date: Thu, 02 Jan 1997 02:08:16 +0100 From: haase@alkor.sax.de (Uwe Haase) X-Newsreader: UPoint-'medium' (03. Apr. '95) References: <852096106_OASIS_@stainsby.demon.co.uk> <19961231193500.OAA18218@ladder01.news.aol.com> <32c96e8f.25996581@news.airtime.co.uk> Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Length: 1097 Lines: 34 In <32c96e8f.25996581@news.airtime.co.uk> Tony Greenwood wrote: > Looking forward to this tutorial myself, but buggered if I can get >hold of a C compiler ??? FYI: There are also C compilers available free of charge. - Sozobon C - GNU C/C++ Both are not for beginners, (no IDE) and demand a lot of RAM and disk space. At least 4 MB RAM and about 5..20 MB empty disk space. Chatwin from Dirk Haun is a shareware development environment for nearly all programming languages. You can find the related files on several ftp servers: sunsite.cnam.fr/pub/Atari/Programming/soz*.zoo Sozobon C V. 2.0 ftp.uni-kl.de/pub/atari/languages/gcc/* GNU C 2.6.3 (version 2.6.3 is old but more stable than 2.7.x) There was a HiSoft C interpreter on coverdisk of ST Format 71. This one is good for doing the very first steps in C, no large configuration files and so on, it fits on 2 disks. Disadvantages: No executable output, IDE not very compatible for newer ataris. -- Email: haase@alkor.sax.de . From: stosser@airtime.co.uk (Tony Greenwood) Newsgroups: comp.sys.atari.programmer Subject: C Lesson 1 Date: Wed, 01 Jan 1997 10:35:27 GMT Organization: STOSSER Software Lines: 16 Message-ID: <32c9b18b.43147177@news.airtime.co.uk> Reply-To: stosser@airtime.co.uk NNTP-Posting-Host: stosser.airtime.co.uk X-Newsreader: Forte Agent .99e/32.201 Path: news.demon.co.uk!dispatch.news.demon.net!demon!uknet!usenet1.news.uk.psi.net!uknet!EU.net!Austria.EU.net!01-newsfeed.univie.ac.at!swidir.switch.ch!in2p3.fr!oleane!plug.news.pipex.net!pipex!news.frontline.co.uk!hole.news.pipex.net!pipex!bowl.news.pi ex.net!pipex!news.airtime.co.uk!usenet I compiled the small C program from lesson 1, The compiled program IS 23306 Bytes, sound right? Using GST C...Anyone have any opinions on this C ???? please? Cheers..............!ynoT Tony Greenwood ( STOSSER Software ) stosser@airtime.co.uk irc #ATARI http://www.airtime.co.uk/users/stosser Keeper of the STOS.FAQ and Joint Maintainer of the STOS FTP Site Path: news.demon.co.uk!dispatch.news.demon.net!demon!nest.demon.co.uk!nest.demon.co.uk!RCain From: RCain@nest.demon.co.uk (Roger Cain) Newsgroups: comp.sys.atari.programmer Subject: C Lesson 1 Date: Thu, 02 Jan 97 12:38:28 Organization: Network ST (NeST) Lines: 26 Message-ID: <671_RCain@nest.demon.co.uk> Reply-To: RCain@nest.demon.co.uk NNTP-Posting-Host: nest.demon.co.uk X-NNTP-Posting-Host: nest.demon.co.uk Content-transfer-encoding: 8BIT X-Mailer: Net2Net (3.57) BETA (NON WINDOW VERSION) Hi stosser@airtime.co.uk, on 01 Jan 97 you wrote: s> s> I compiled the small C program from lesson 1, s> s> The compiled program IS 23306 Bytes, sound right? s> s> Using GST C...Anyone have any opinions on this C ???? please? Almost anything you do, however small, will cause library(s) to be linked into the program. There is a "zero-code" overhead! Relax! The library(s) are only linked once - you can go on to write megabytes of your own code with no further overhead. Roger rcain@nest.demon.co.uk -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Via the Net2Net NeST gateway - 90:100/999 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ . Path: news.demon.co.uk!dispatch.news.demon.net!demon!news.sprintlink.net!news-peer.sprintlink.net!howland.erols.net!feed1.news.erols.com!insync!news.hal-pc.org!conchbbs!7861!john.kormylo From: John.Kormylo@7861.conchbbs.com (John Kormylo) Newsgroups: comp.sys.atari.programmer Subject: C Lesson 1 Date: 03 Jan 97 10:21:02 Organization: Houston Area League of PC Users Lines: 24 Message-ID: <3a8_9701032040@conchbbs.com> NNTP-Posting-Host: conchbbs.com X-FTN-To: stosser@airtime.co.uk s > ho?....so the whole library is used when you only need part of s > it?, That depends on the linker. The main problem is that printf() can format strings, chars, ints, longs, and floats, and calls a bunch of other functions to handle all of these cases. It also uses stream I/O, which requires a considerable number of functions to handle its buffering and error handling peculiarities. It also needs to parse the format string. You could save considerable amounts of RAM calling functions like Cconws(), strcat() and ltoa() and doing all of the formatting yourself, but that is hardly to goal of a tutorial. ___ Mountain Reader II - #00000053 -- |Fidonet: John Kormylo 1:106/7861 |Internet: John.Kormylo@7861.conchbbs.com | | Standard disclaimer: The views of this user are strictly his own. . Path: news.demon.co.uk!dispatch.news.demon.net!demon!news.bbnplanet.com!cam-news-hub1.bbnplanet.com!news.mathworks.com!news-xfer.netaxs.com!insync!news-feed.inet.tele.dk!sn.no!nntp-oslo.UNINETT.no!nntp-trd.UNINETT.no!newsfeed.sunet.se!news99.sunet.se!new .chalmers.se!dtek.chalmers.se!d8klojo From: d8klojo@dtek.chalmers.se (Johan Klockars) Newsgroups: comp.sys.atari.programmer Subject: Re: Intro. to C tutorial, part 1 Date: 2 Jan 1997 02:20:10 GMT Organization: Chalmers University of Technology Lines: 57 Message-ID: <5af60q$46d@nyheter.chalmers.se> References: <19961230174500.MAA13314@ladder01.news.aol.com> NNTP-Posting-Host: stettin.dtek.chalmers.se In article <19961230174500.MAA13314@ladder01.news.aol.com>, RDupuy5596 wrote: .... >--What is C? What is C++? .... >C++ is in some respects an entirely different language than C. Over the >years, however C and C++ have melded in function. You must know C to Well, C++ was based on C. I think the ANSI-C standard did indeed take a few features from the newer language, though. >understand C++. Some people learning C++ learn C at the same time, Unless you do very strange things, chances are good that your C program is also a C++ program without you even knowing it. ;-) You can well do without the things in C that are different in C++. (I just tried to remember a difference, but I couldn't...) >however it is wise to learn C first, and thoroughly before moving on to Many people would disagree with that. I'm one of them. You can easily use C++ as a 'better C' and not bother with the object oriented things. The compiler will protect you from more stupid errors and you can take advantage of many nice features. Learning object oriented programming from the start is probably also a very good idea. >--Should I learn C or BASIC first? > >The fundamentals of programming, i.e. accepting input, manipulating data, >formatting output, are universal regardless of which language you choose I guess this isn't the place to go into imperative vs logic vs functional (vs whatever) programming. ;-) >will find useful in other environments. There are versions of BASIC >available free for the Atari computer, whereas C usually costs money. It Hmm, apart from one or two BASIC versions that were released on magazine disks, I've not heard of a free one. On the other hand, there are several free C compilers. >may be wise to start programming in BASIC to see how well you like >programming, although C compilers are pretty inexpensive nowadays. C has I'd rather say the main reason for using a traditional (interpreted) BASIC is that you can more easily test (not too complex) things out. It's very easy to crash the computer using C and you always have to wait for recompiles. -- Chalmers University | Why are these | e-mail: rand@cd.chalmers.se of Technology | .signatures | johan@rand.thn.htu.se | so hard to do | WWW/ftp: rand.thn.htu.se Gothenburg, Sweden | well? | (MGIFv5, QLem, BAD MOOD) Path: news.demon.co.uk!dispatch.news.demon.net!demon!news.sprintlink.net!news-peer.sprintlink.net!howland.erols.net!portc02.blue.aol.com!audrey01.news.aol.com!not-for-mail From: rdupuy5596@aol.com (RDupuy5596) Newsgroups: comp.sys.atari.programmer Subject: Re: Intro. to C tutorial, part 1 Date: 4 Jan 1997 22:40:42 GMT Organization: AOL http://www.aol.com Lines: 18 Message-ID: <19970104223900.RAA01642@ladder01.news.aol.com> References: <5af60q$46d@nyheter.chalmers.se> NNTP-Posting-Host: ladder01.news.aol.com X-Admin: news@aol.com In my first writing of the introduction, I was under the impression that a certain unnamed BASIC was free, which in fact, it turns out is not free. However, with most computers, C64, Atari 800 or MS-DOS, have a free version of BASIC included (Commodore BASIC, Atari BASIC or GW BASIC) what have you...If there are free versions of C for TOS, then PLEASE, seriously PLEASE tell me where to find them so I can test my programs on this compiler and tell all those people who do not have compilers where they can get one. That will solve some of the problems related to this tutorial. As for your other comments, I'm not going to argue with them, the fact is there are some good points in your posting, and .... C and C++ are related languages, obviously, but the concept of programming object oriented code places an emphasis on different skills...in any event so few Atarians have a C++ compiler that the point is moot. . Path: news.demon.co.uk!dispatch.news.demon.net!demon!news-lond.gsl.net!news.gsl.net!news-stkh.gsl.net!news.gsl.net!sn.no!nntp-oslo.UNINETT.no!nntp-trd.UNINETT.no!newsfeed.sunet.se!news99.sunet.se!news.chalmers.se!dtek.chalmers.se!d8klojo From: d8klojo@dtek.chalmers.se (Johan Klockars) Newsgroups: comp.sys.atari.programmer Subject: Re: C Lesson 1 Date: 2 Jan 1997 02:33:22 GMT Organization: Chalmers University of Technology Lines: 31 Message-ID: <5af6pi$474@nyheter.chalmers.se> References: <32c9b18b.43147177@news.airtime.co.uk> NNTP-Posting-Host: stettin.dtek.chalmers.se In article <32c9b18b.43147177@news.airtime.co.uk>, Tony Greenwood wrote: > >I compiled the small C program from lesson 1, > >The compiled program IS 23306 Bytes, sound right? That sounds reasonable. Your main() function is probably no more than 50 bytes or so, but the printf() library function can be quite large. Your executable also includes a bunch of stuff used by the initialization code that's run before the call to main(). >Using GST C...Anyone have any opinions on this C ???? please? I wonder how many even remembers it. ;-) The code quality of such an early compiler is not likely to be very good and it probably doesn't handle function prototypes or other ANSI-C stuff. It's quite possible that it will be OK for this course, though. Will the course be using ANSI-C, by the way? If not, I hope there will at least be function prototypes. (Does Laser C have that?) -- Chalmers University | Why are these | e-mail: rand@cd.chalmers.se of Technology | .signatures | johan@rand.thn.htu.se | so hard to do | WWW/ftp: rand.thn.htu.se Gothenburg, Sweden | well? | (MGIFv5, QLem, BAD MOOD) . Path: news.demon.co.uk!dispatch.news.demon.net!demon!news.bbnplanet.com!cpk-news-hub1.bbnplanet.com!feed1.news.erols.com!howland.erols.net!blackbush.xlink.net!fu-berlin.de!news.th-darmstadt.de!news.uni-mainz.de!news.uni-hamburg.de!news.dkrz.de!newsserver rrzn.uni-hannover.de!pallas.amp.uni-hannover.de!perot From: Peter Rottengatter Newsgroups: comp.sys.atari.programmer Subject: Re: C Lesson 1 Date: Thu, 2 Jan 1997 10:21:04 +0100 Organization: RRZN - Newsserver Lines: 30 Message-ID: References: <32c9b18b.43147177@news.airtime.co.uk> NNTP-Posting-Host: pallas.amp.uni-hannover.de Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII In-Reply-To: <32c9b18b.43147177@news.airtime.co.uk> On Wed, 1 Jan 1997, Tony Greenwood wrote: > I compiled the small C program from lesson 1, > > The compiled program IS 23306 Bytes, sound right? Sounds right. The reason is that printf() is a super duper function that is able to do virtually everything in terms of text output. It thus takes some space. There are smaller, more specialized functions, I'm sure they will be covered in later lessons. > Using GST C...Anyone have any opinions on this C ???? please? It's a rather old, not all too efficient c-compiler. But this holds for the lessons reference compiler Laser C too. It should certainly do everything required for this series of lessons. But it also means that you should not despair if you can't get a sample program to work, you might have come across a compiler bug. This happened to me, I learned programming C using Megamax C and a few times I was close to despair. But with growing experience you learn how to destinguish compiler bugs from your own ones. Cheers Peter --------------------------------------------------------------------- Peter Rottengatter perot@pallas.amp.uni-hannover.de --------------------------------------------------------------------- From: stosser@airtime.co.uk (Tony Greenwood) Newsgroups: comp.sys.atari.programmer Subject: Re: C Lesson 1 Date: Thu, 02 Jan 1997 11:45:40 GMT Organization: STOSSER Software Lines: 43 Message-ID: <32cb9e4c.3999979@news.airtime.co.uk> References: <32c9b18b.43147177@news.airtime.co.uk> <5af6pi$474@nyheter.chalmers.se> Reply-To: stosser@airtime.co.uk NNTP-Posting-Host: stosser.airtime.co.uk X-Newsreader: Forte Agent .99e/32.201 Path: news.demon.co.uk!dispatch.news.demon.net!demon!news.bbnplanet.com!cam-news-hub1.bbnplanet.com!uunet!in2.uu.net!193.10.88.100!news00.sunet.se!sunic!mn6.swip.net!plug.news.pipex.net!pipex!hole.news.pipex.net!pipex!bowl.news.pipex.net!pipex!news.azure com!dish.news.pipex.net!pipex!news.airtime.co.uk!usenet On 2 Jan 1997 02:33:22 GMT, d8klojo@dtek.chalmers.se (Johan Klockars) wrote: >>The compiled program IS 23306 Bytes, sound right? > >That sounds reasonable. Good, you see I had three compiler options, it would seem compile link is the one to use :) >Your main() function is probably no more than 50 bytes or so, but the >printf() library function can be quite large. Your executable also includes >a bunch of stuff used by the initialization code that's run before the call >to main(). ho?....so the whole library is used when you only need part of it?, >>Using GST C...Anyone have any opinions on this C ???? please? >I wonder how many even remembers it. ;-) ho dear ? >The code quality of such an early compiler is not likely to be very good ho dear ho dear ho dear :( >and it probably doesn't handle function prototypes or other ANSI-C stuff. ho no....:( >It's quite possible that it will be OK for this course, though. Hooooray!!! :)))))) not a total waste of money then :) Thank you, that cleared up a couple of points....FANX! Cheers..............!ynoT Tony Greenwood ( STOSSER Software ) stosser@airtime.co.uk irc #ATARI http://www.airtime.co.uk/users/stosser Keeper of the STOS.FAQ and Joint Maintainer of the STOS FTP Site Path: news.demon.co.uk!dispatch.news.demon.net!demon!swampdog.demon.co.uk!swampdog.demon.co.uk!guy From: guy@swampdog.demon.co.uk (Guy Harrison) Newsgroups: comp.sys.atari.programmer Subject: Re: C Lesson 1 Date: Thu, 2 Jan 97 17:59:42 GMT Lines: 34 Message-ID: <852227982_OASIS_@swampdog.demon.co.uk> Reply-To: guy@swampdog.demon.co.uk NNTP-Posting-Host: swampdog.demon.co.uk X-NNTP-Posting-Host: swampdog.demon.co.uk Organisation: SwampDog X-Newsreader: OASIS Daily Net (Atari) v1.33E In article <32cb9e4c.3999979@news.airtime.co.uk> stosser@airtime.co.uk (Tony Greenwood) said:- > ho?....so the whole library is used when you only need part of it?, Yes & No. :-) printf() calls other functions so the linker has to fetch them as well, plus any functions those functions happen to call, and so on. This only happens once though - you can make another million printf() calls and it won't fetch any of it again, even if you call one of the lower level functions yourself. Just to give you an idea of how complex printf() is, when I compile this ... main() { printf("Hello\n"); } ... my compiler has to dig out 42 other functions! __ Guy Harrison Email guy@swampdog.demon.co.uk swampdog@dial.pipex.com Web http://www.swampdog.demon.co.uk/index.html . Path: news.demon.co.uk!dispatch.news.demon.net!demon!news.sprintlink.net!news-peer.sprintlink.net!howland.erols.net!feed1.news.erols.com!insync!news.hal-pc.org!conchbbs!7861!john.kormylo From: John.Kormylo@7861.conchbbs.com (John Kormylo) Newsgroups: comp.sys.atari.programmer Subject: C Tutorial Chart Date: 06 Jan 97 10:18:00 Organization: Houston Area League of PC Users Lines: 19 Message-ID: <012_9701061642@conchbbs.com> NNTP-Posting-Host: conchbbs.com X-FTN-To: mr_ni@mbh.org m > In Pure C floats and doubles are the same thing. You mean doubles and long doubles are the same thing. floats are still 4 bytes. Even more confusing, sizeof(double) varies depending on the compiler options. Normally, sizeof(double) == 10, but when using the FPU sizeof(double) == 12. The accuracy doesn't change, but the FPU uses the extra 2 bytes during it's internal operations. ___ Mountain Reader II - #00000053 -- |Fidonet: John Kormylo 1:106/7861 |Internet: John.Kormylo@7861.conchbbs.com | | Standard disclaimer: The views of this user are strictly his own. . Path: news.demon.co.uk!dispatch.news.demon.net!demon!news.bbnplanet.com!cpk-news-hub1.bbnplanet.com!worldnet.att.net!feed1.news.erols.com!cwix!uunet!in1.uu.net!194.158.161.17!newsgw.mbh.org!p24.f101.n323.z205!not-for-mail Newsgroups: comp.sys.atari.programmer Distribution: world X-Comment-To: All From: Hans Wessels Reply-To: mr_ni@mbh.org Date: Sun, 05 Jan 97 16:47:12 +0100 Subject: Re: C Tutorial Chart Message-ID: <852480627@p24.f101.n323.z205.mbh.org> References: <1587638962@ladder01.news.aol.com> Organization: MBH (070-3605991) X-FTN-AREA: COMP.SYS.ATARI.PROGRAMMER X-FTN-MSGID: 205:323/101.24@mbh 32cfd273 X-FTN-REPLY: ladder01.news.aol.com 5ea172b2 X-FTN-PID: LED 1.25 X-FTN-Tearline: Tachion 0.99beta14 X-FTN-Origin: MBH (070-3605991) (mbh 205:323/101.24) X-FTN-SEEN-BY: 323/100 X-FTN-PATH: 323/100 Lines: 47 rdupuy5596@aol.com wrote: > Variable type | Keyword | Memory Useage | Use > > integer | int | 2 bytes | Whole numbers > | -32,768 to > | +32,768 Ho, stop, now we are in compiler specific things. Time to grap the ANSI standard and correct a few things. An int is guaranteed to be 16 bit, 32 bit many compilers, like Lattice C, use 32 bit ints. > long integer | long | 4 bytes | Whole numbers > | -2,147,483,648 to > | +2,147,483,648 Same thing here, a long is at least 32 bit, bit it can also be bigger, like 64 bit on a Alpha processor. > floating point | float | 4 bytes | Measured values > | +/- 10E38 > | 6 digits of precision > > double float | double | 8 bytes | Measured values > | +/- 10E308 > |15 digits of precision Same thing here. In Pure C floats and doubles are the same thing. The minimum number of digits of a double is 10. The minimum value of a float or double is at least 10E-37, the maximum value is at least 10E37 > character | char | 1 byte | non numeric values > | -128 to 127 Compiler specific, some compilers use unsigned chars by default, other use signed chars by default. All quoted values come from my copy of K&R2, not from the real ANSI standard, but there aren't much differences between K&R2 and ANSI. The exact minimum and maximum values of all these types can be found in limits.h. Bye, Hans Wessels . Path: news.demon.co.uk!dispatch.news.demon.net!demon!swampdog.demon.co.uk!swampdog.demon.co.uk!guy From: guy@swampdog.demon.co.uk (Guy Harrison) Newsgroups: comp.sys.atari.programmer Subject: Re: C Tutorial Chart Date: Mon, 6 Jan 97 13:53:30 GMT Lines: 140 Message-ID: <852558810_OASIS_@swampdog.demon.co.uk> Reply-To: guy@swampdog.demon.co.uk NNTP-Posting-Host: swampdog.demon.co.uk X-NNTP-Posting-Host: swampdog.demon.co.uk Organisation: SwampDog X-Newsreader: OASIS Daily Net (Atari) v1.33E In article <852480627@p24.f101.n323.z205.mbh.org> Hans Wessels said:- >rdupuy5596@aol.com wrote: > > > Variable type | Keyword | Memory Useage | Use > > > > integer | int | 2 bytes | Whole numbers > > | -32,768 to > > | +32,768 > >Ho, stop, now we are in compiler specific things. Time to grap the ANSI >standard and correct a few things. > >An int is guaranteed to be 16 bit, 32 bit many compilers, like Lattice C, use >32 bit ints. > > > long integer | long | 4 bytes | Whole numbers > > | -2,147,483,648 to > > | +2,147,483,648 > >Same thing here, a long is at least 32 bit, bit it can also be bigger, like 64 >bit on a Alpha processor. > > > floating point | float | 4 bytes | Measured values > > | +/- 10E38 > > | 6 digits of precision > > > > double float | double | 8 bytes | Measured values > > | +/- 10E308 > > |15 digits of precision > >Same thing here. In Pure C floats and doubles are the same thing. The minimum >number of digits of a double is 10. The minimum value of a float or double is at >least 10E-37, the maximum value is at least 10E37 > > > character | char | 1 byte | non numeric values > > | -128 to 127 > >Compiler specific, some compilers use unsigned chars by default, other use >signed chars by default. > >All quoted values come from my copy of K&R2, not from the real ANSI standard, >but there aren't much differences between K&R2 and ANSI. > >The exact minimum and maximum values of all these types can be found in >limits.h. Yep Hans, I wondered if I ought to say anything myself - guess I should have but I couldn't think how to say it in non technical terms yesterday! Here's today's effort ;-) ... Firstly, people ought to check with their compiler manual. Like any language, there is no guarantee a particular datatype on one compiler uses the same amount of space as the next compiler. 'C' tries to help with this by having certain rules. Basically, the fundamental unit of storage is 'char' - all other datatypes use x amount of 'char' for storage. You can also assume this ... 'short' always uses the same or more space as 'char'. 'long' always uses the same or more space as 'short'. 'int' is either 'short' or 'long' - see your compiler docs for which. There is a function to help deal with this called sizeof(). It returns the number of 'char' units required to store the datatype, even ones you make up yourself. Thus sizeof(char) is always 1, sizeof(short) is always >= sizeof(char), and sizeof(long) is always >= sizeof(short). There's still a problem. We do not know how big a 'char' is. This gets into the realm of portability - a complex and vague issue so I'll be atari specific now ... sizeof(char) = 1 byte. sizeof(short) = 2 bytes. sizeof(long) = 4 bytes. sizeof(int) = either 2 or 4 bytes. This little program will tell you how many bytes an 'int' needs in its signed and unsigned states ... main() { printf("6\n",sizeof(signed int)); printf("6\n",sizeof(unsigned int)); } In almost all cases there will be no problem - the compiler will sort it out for you. Those of you with K&R compilers will have to be a little more careful though because the compiler cannot tell if you are passing garbage between functions. One area to keep an eye on is printf() and similar functions like fprintf() and sprintf(). A common cause of error is something like this ... main() {long l =5; printf("6\n",l); } Now, this may or may not work depending on your compiler *but* in either case it _is_ 'broken'. There are three fixes ... /* if you really wanted to print a long */ main() {long l =5; printf("6\n",l); ----------^------------ long decimal } /* if you really wanted to print an int */ main() {int l =5; -^^^------------------- declare it properly printf("6\n",l): } /* if you want a long printed as an int */ main() {long l =5; printf("6\n",(int)l); ---------------^^^^^--- forces the compiler to convert it } See, just shows how powerful 'C' is - three ways to fix two lines of code! ;-) __ Guy Harrison Email guy@swampdog.demon.co.uk swampdog@dial.pipex.com Web http://www.swampdog.demon.co.uk/index.html . Path: news.demon.co.uk!dispatch.news.demon.net!demon!news.bbnplanet.com!cpk-news-hub1.bbnplanet.com!worldnet.att.net!news.mathworks.com!howland.erols.net!surfnet.nl!newsfeed.sunet.se!news99.sunet.se!news.chalmers.se!dtek.chalmers.se!d8klojo From: d8klojo@dtek.chalmers.se (Johan Klockars) Newsgroups: comp.sys.atari.programmer Subject: Re: C Tutorial Chart Date: 6 Jan 1997 20:00:04 GMT Organization: Chalmers University of Technology Lines: 72 Message-ID: <5arlk4$3la@nyheter.chalmers.se> References: <1587638962@ladder01.news.aol.com> <852480627@p24.f101.n323.z205.mbh.org> NNTP-Posting-Host: stettin.dtek.chalmers.se In article <852480627@p24.f101.n323.z205.mbh.org>, Hans Wessels wrote: >rdupuy5596@aol.com wrote: ... > > integer | int | 2 bytes | Whole numbers > > | -32,768 to > > | +32,768 > >Ho, stop, now we are in compiler specific things. Time to grap the ANSI >standard and correct a few things. > >An int is guaranteed to be 16 bit, 32 bit many compilers, like Lattice C, use >32 bit ints. There is, however, a switch in Lattice (and in GCC for that matter) to make an 'int' 16 bit. (WARNING! The Lattice C optimizer often does some incredibly stupid things when it tries to optimize code which uses 16 bit numbers. You might even be better off with no optimization at all...) The range for a 16 bit (2-complement) number is -32768 to +32767, by the way. Normally, an 'int' should be the 'natural' integer type for the machine in question. Unfortunately, the older members of the Motorola 68k series (like the 68000 in the STs) are only 16 bit internally (except for the registers), while having a 32 bit instruction set architecture (ISA). This is probably the cause for the confusing compiler differences. (The PCs with their 80x86s have the same problem.) > > long integer | long | 4 bytes | Whole numbers > > | -2,147,483,648 to > > | +2,147,483,648 > >Same thing here, a long is at least 32 bit, bit it can also be bigger, like 64 >bit on a Alpha processor. And again, the second range figure should end with a 7. > > character | char | 1 byte | non numeric values 'non numeric'? There are lots of cases where it's very useful to use characters in the same way as any other number type. C makes no distinction. > > | -128 to 127 > >Compiler specific, some compilers use unsigned chars by default, other use >signed chars by default. And many can change that via a switch. Also, a character may well be longer than 8 bits. You won't find any Atari compiler where that is so, though. (I've heard of 9 bit and 64 bit character machines, but those are not something I would worry about. ;-) By the way, you forgot to mention 'short' (perhaps not very surprising if you're using a compiler that has a 16 bit 'int' ;-). 'short' is at least 16 bit and no longer than an 'int'. On machines where the latter is 32 bit, 'short' is often 16 bit to make a more space efficient type available. It can be slower to do calculations with 'short', though. Length of char <= short <= int <= long. (GCC also has 'long long' which is 64 bit, but that's not standard.) -- Chalmers University | Why are these | e-mail: rand@cd.chalmers.se of Technology | .signatures | johan@rand.thn.htu.se | so hard to do | WWW/ftp: rand.thn.htu.se Gothenburg, Sweden | well? | (MGIFv5, QLem, BAD MOOD) . Path: news.demon.co.uk!dispatch.news.demon.net!demon!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!cam-news-hub1.bbnplanet.com!uunet!in3.uu.net!194.158.161.17!newsgw.mbh.org!p24.f101.n323.z205!not-for-mail Newsgroups: comp.sys.atari.programmer Distribution: world X-Comment-To: All From: Hans Wessels Reply-To: mr_ni@mbh.org Date: Tue, 07 Jan 97 22:23:54 +0100 Subject: Re: C Tutorial Chart Message-ID: <852674068@p24.f101.n323.z205.mbh.org> References: <1995747665@swampdog.demon.co.uk> Organization: MBH (070-3605991) X-FTN-AREA: COMP.SYS.ATARI.PROGRAMMER X-FTN-MSGID: 205:323/101.24@mbh 32d2c614 X-FTN-REPLY: swampdog.demon.co.uk 76f4b151 X-FTN-PID: LED 1.25 X-FTN-Tearline: Tachion 0.99beta14 X-FTN-Origin: MBH (070-3605991) (mbh 205:323/101.24) X-FTN-SEEN-BY: 323/100 X-FTN-PATH: 323/100 Lines: 93 Guy Harrison wrote: > There's still a problem. We do not know how big a 'char' is. This > gets into the realm of portability - a complex and vague issue so I'll > be atari specific now ... The constant CHAR_BIT in limits.h tells you how many bits there are in a char. Usually it's eight. > > sizeof(char) = 1 byte. > sizeof(short) = 2 bytes. > sizeof(long) = 4 bytes. > sizeof(int) = either 2 or 4 bytes. > > This little program will tell you how many bytes an 'int' needs in > its signed and unsigned states ... > > main() > { > printf("6\n",sizeof(signed int)); > printf("6\n",sizeof(unsigned int)); > } > Well Mr Harrisson, you made a mistake overhere, this program will print when compiled and runned: 6 6 Not very usefull I think. Let's do it this way... #include int main(void) /* main has to be of the type int according to ANSI */ { printf("%i\n", (int)sizeof(signed int)); printf("%i\n", (int)sizeof(unsigned int)); return 0; /* exit succes */ } The operator sizeof() has an result of the type size_t, the type of size_t is compiler dependent. That's why I cast the answer to an int. > In almost all cases there will be no problem - the compiler will sort > it out for you. Those of you with K&R compilers will have to be a > little more careful though because the compiler cannot tell if you > are passing garbage between functions. For those who don't know: there are two main streams in C compilers, the older K&R compilers and the newer ANSI C compilers. The main advantage of ANSI C is that there are function prototypes, so the compiler can check wether you are passing variables of the right type to a function. The K&R compilers are called K&R compilers because the compile C the way it was defined in 'The C programming language' by Kerninghan and Ritchie. ANSI C compilers are implemented according the ANSI C standard. A good book about ANSI C is 'The C programming language, second edition' by Kerninghan and Ritchie. Those books by Kerninghan and Ritchie are usually reffered to as K&R. To avoid any confusion about which book you are reffering to you can use K&R1 and K&R2 for the first c.q. second edition. > One area to keep an eye on is printf() and similar functions like > fprintf() and sprintf(). A common cause of error is something like > this ... > > main() > {long l =5; > > printf("6\n",l); printf("%i\n", l); /* ??? */ > } > > Now, this may or may not work depending on your compiler *but* in > either case it _is_ 'broken'. There are three fixes ... > > /* if you really wanted to print a long */ > main() > {long l =5; > > printf("6\n",l); > ----------^------------ long decimal printf("%li\n", l); etc. Bye, Hans Wessels . Path: news.demon.co.uk!dispatch.news.demon.net!demon!news.sprintlink.net!news-peer.sprintlink.net!uunet!in3.uu.net!194.158.161.17!newsgw.mbh.org!p24.f101.n323.z205!not-for-mail Newsgroups: comp.sys.atari.programmer Distribution: world X-Comment-To: All From: Hans Wessels Reply-To: mr_ni@mbh.org Date: Wed, 08 Jan 97 19:52:58 +0100 Subject: Re: C Tutorial Chart Message-ID: <852750352@p24.f101.n323.z205.mbh.org> References: <4199902643@pallas.amp.uni-hannover.de> Organization: MBH (070-3605991) X-FTN-AREA: COMP.SYS.ATARI.PROGRAMMER X-FTN-MSGID: 205:323/101.24@mbh 32d3f010 X-FTN-REPLY: pallas.amp.uni-hannover.de fa556db3 X-FTN-PID: LED 1.25 X-FTN-Tearline: Tachion 0.99beta14 X-FTN-Origin: MBH (070-3605991) (mbh 205:323/101.24) X-FTN-SEEN-BY: 323/100 X-FTN-PATH: 323/100 Lines: 22 Wrote: Peter Rottengatter > > On 6 Jan 1997, Johan Klockars wrote: > >> Normally, an 'int' should be the 'natural' integer type for the >> machine in question. Unfortunately, the older members of the Motorola >> 68k series (like the 68000 in the STs) are only 16 bit internally >> (except for the registers), while having a 32 bit instruction set >> architecture (ISA). > > This is wrong. Even the 68000 is 32 bit internally. Instructions like > adding 32 bit numbers would take far more time if this were not the > case. Turn it around, then it makes more sense : The MC68000 is a full > 32 bit processor that has a 24 bit address and 16 bit data bus > interface. I think the ALU of the 68000 is only 16 bit, register to register addition of a long take 8 clockcycli, while a word addition only takes 4 clockcycli. So I think that Johan Klockars is right with his statement. Bye, Hans Wessels .