473,855 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A C tutorial

There is a C tutorial at
http://www.cs.virginia.edu/~lcc-win32
It is written to go with the compiler, available
at the same URL.

I have added quite a bit of material, and I would be
glad if people in this group give it a try and tell me if
I am saying nonsense somewhere.

Beware that I am not very orthodox, hence my tutorial
(and the associated compiler) is not just a tutorial about
ANSI C, but covers things like operator overloading and
other heresies :-)

And since it is running in a specific OS, windows
programming makes for quite a lot of pages. If you
use another OS however, the first part is (almost)
straight C.

jacob

Nov 14 '05
156 7740
nrk wrote:
Richard Heathfield wrote:
Mark McIntyre wrote:
On Fri, 13 Feb 2004 19:38:11 +0000 (UTC), in comp.lang.c , Richard
Heathfield <do******@addre ss.co.uk.invali d> wrote:

Yes, he did, but it's not as if I'm asking him to write a full reader.
Just a simple little word-length histogram program.

??? 1.13 asks me to return the lower case of the program's input, or the
input unmodified, should that not be a letter.
Would this be the Mark McIntyre edition of K&R2, then?

K&R2, page 24: "Exercise 1-13. Write a program to print a histogram of
the lengths of words in its input..."
but your one (1.12) is just as easy. I'll define a word break as any
whitespace character in the input, and off I go.


Ex 1-12 asks you to print one word per line. Okay, so you say it's easy.
So why not demonstrate that it's easy?

If pdf processing is so
easy, he shouldn't find this to be a major challenge.

Its not.


Prove it.


But perhaps he has to
open a file or something, in which case I agree that the restriction
would be a bit harsh.

Pipe is your friend. After all, you can't process a text /file/ via the
same program without it.

But 1-13 is a different matter.

Its certainly a good attempt to change the subject from file readers to
something totally different. Nice try.


Excuse me? It's not totally different /at all/. What's the matter - is it
suddenly hard to process PDF files? I thought you said it wasn't.

But okay, if you /think/ it's different, just show me a cat for PDF.
Presumably that's easy too, right?

Actually, its not all that hard.

system("pdftote xt file.pdf");
system("cat file.txt");

Smile. It's supposed to be funny.


Oh, it is. Highly amusing, in fact. Have the film rights gone?
Seriously though, there is a utility
called pdftotext. It doesn't really do a great job in terms of rendering
readable text from pdf, but for purposes of solving the proposed exercise,
it should be enough to use this and pipe the output through your standard
C solution for text files :-)


No, not really. The output from pdftotext sucks. It's certainly not good
enough for comp.lang.c, IMHO. Furthermore, the availability of pdftotext
and cat is not guaranteed by ISO C, so your system() calls might fail to do
what is expected of them.

--
Richard Heathfield : bi****@eton.pow ernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 14 '05 #131
Mark McIntyre wrote:
On Sat, 14 Feb 2004 05:55:59 +0000 (UTC), in comp.lang.c , Richard
Heathfield <do******@addre ss.co.uk.invali d> wrote:
Mark McIntyre wrote:
but your one (1.12) is just as easy. I'll define a word break as any
whitespace character in the input, and off I go.
Ex 1-12 asks you to print one word per line. Okay, so you say it's easy.
So why not demonstrate that it's easy?


*sigh*

Are you clinically thick on this point?


No. If you really, really think that I am, though, then there is no point
whatsoever in continuing this discussion.

Here's the algo, you go implement it.
I already did, for text files. You said processing PDFs is easy. I want you
to show me how easy it is, by answering a really, really simple exercise
using PDF instead of text as input. Is that so hard to understand?

Let me see:
I was talking about writing a file reader for pdfs in standard C.
You wanted me to answer some K&R exercise using only a subset of standard
C.


....specificall y using a PDF file as input, rather than a normal text file.

Either you can process PDF data easily or you can't. Put up or shut up, as
the saying goes.

What's the matter - is it
suddenly hard to process PDF files? I thought you said it wasn't.
But okay, if you /think/ it's different, just show me a cat for PDF.
Presumably that's easy too, right?


Yup. You really are being clinically thick, aren't you?


If you say so. Now, show me how clever you are - show me how to write a PDF
cat in ISO C. You may not assume that PDF processing facilities exist
elsewhere - i.e. system() calls to pdftotext and cat don't cut it.

--
Richard Heathfield : bi****@eton.pow ernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 14 '05 #132
Mark McIntyre wrote:
On Sat, 14 Feb 2004 05:46:00 +0000 (UTC), in comp.lang.c , Richard
Heathfield <do******@addre ss.co.uk.invali d> wrote:
Mark McIntyre wrote:

Sure, for Eur 150/hour. :-)
Then it can hardly be as easy as you claim.


No, thats just my hourly rate for answering homework questions.


This isn't homework. You made a claim, and now you refuse to back it up. I
conclude that the claim is insupportable. If you think I'm wrong, *prove*
it.
For example, please solve exercise 1-13 in K&R2, using a
PDF file instead of a text file as input. Please restrict yourself to
those parts of C introduced in those first 24 pages, to make it a fair
compariso n.

As it happens, this is ludicrously easy.


Prove it.


Golly, prove that you can convert uppercase characters in a stream of data
into lowercase ones using only standard C? oooo thats tricky....


Learn To Read. Then Turn To Page 24 Of K&R2, And Read Exercise 1-13.

Note also that you are /not/ using a normal data stream, but a PDF file. It
is your program's job to interpret that file correctly so that the purposes
of the exercise are correctly satisfied.

You need to think a little harder.


Nope. You are the one making the claim (that PDF processing is as easy as
text processing).


Indeed. But thats not what you asked me to do.


Yes, it is.
You asked me to solve K&R2 1.13. Now in my copy thats
"write a program to convert its input to lower case, using a function
lower(c) which returns c if c is not a letter, and the lower case value of
c if it is a letter"


Then get a book that has the same 1.13 as everyone else's 1.13.

By the way, where did I mention that you could use only the first 24
pages of K&R?


You didn't, but you said that PDF processing was as easy as text
processing, and I can solve K&R 1-13 using only the information presented
in the first 24 pages of K&R.


Terriffic.


The point, which you appear to have failed to grasp, is that text processing
in C is *easy*. You have claimed that PDF processing is easy, too, but you
apparently can't even solve a simple exercise using PDF input.

Still, as you say, it's quite an arbitrary restriction, so
I don't insist on it as long as the program remains relatively simple.


You'll have to point out where I said it would be a simple /program/. I
said that it was simple to /write/ a program. Call me a pedant if you
like.


I don't have to. You are destroying your own point, blunder by blunder.

Just as a reminder, here is what you claimed: "Its also easy to write tex to
dvi to pcl processors in standard C. Its also easy to write pdf readers in
standard C."

I remain unconvinced.

--
Richard Heathfield : bi****@eton.pow ernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 14 '05 #133
Mark McIntyre wrote:
On Sat, 14 Feb 2004 21:35:07 GMT, in comp.lang.c , nrk
<ra*********@de vnull.verizon.n et> wrote:
Richard Heathfield wrote:
Mark McIntyre wrote:

RJH wrote
> If pdf processing is so
>easy, he shouldn't find this to be a major challenge.

Its not.

Prove it.
Actually, its not all that hard.

system("pdftote xt file.pdf");
system("cat file.txt");

Smile. It's supposed to be funny. Seriously though, there is a utility
called pdftotext.


Oh, rats, you spoiled it.

Richard. Read back through my posts. See if you can spot where I said I
intended to convert the pdf into cutsey graphical output...


I don't have to. You claimed PDF processing is easy, but you appear to be
incapable of supporting your claim.
my proposed
reader does nothing more sophisticated than determine the words in the
pdf, and print them to stdout.
In other words, you appear to be claiming now that PDF processing is so
difficult that the only way you can realistically use PDF data is to turn
it to text data first, and *hope* that the conversion utility got the
conversion right. The obvious strategy, then, is to store the data in text
format to begin with, thus neatly cutting out the middle man. Well done - I
knew you'd get there in the end.

I'm sorry, I've been taking the p*ss.


If you must do that, please learn how to do it properly.

--
Richard Heathfield : bi****@eton.pow ernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 14 '05 #134
nrk
Richard Heathfield wrote:
nrk wrote:
Richard Heathfield wrote:
Mark McIntyre wrote:

On Fri, 13 Feb 2004 19:38:11 +0000 (UTC), in comp.lang.c , Richard
Heathfield <do******@addre ss.co.uk.invali d> wrote:

>Yes, he did, but it's not as if I'm asking him to write a full reader.
>Just a simple little word-length histogram program.

??? 1.13 asks me to return the lower case of the program's input, or
the input unmodified, should that not be a letter.

Would this be the Mark McIntyre edition of K&R2, then?

K&R2, page 24: "Exercise 1-13. Write a program to print a histogram of
the lengths of words in its input..."

but your one (1.12) is just as easy. I'll define a word break as any
whitespace character in the input, and off I go.

Ex 1-12 asks you to print one word per line. Okay, so you say it's easy.
So why not demonstrate that it's easy?
> If pdf processing is so
>easy, he shouldn't find this to be a major challenge.

Its not.

Prove it.

>But perhaps he has to
>open a file or something, in which case I agree that the restriction
>would be a bit harsh.

Pipe is your friend. After all, you can't process a text /file/ via the
same program without it.

>But 1-13 is a different matter.

Its certainly a good attempt to change the subject from file readers to
something totally different. Nice try.

Excuse me? It's not totally different /at all/. What's the matter - is
it suddenly hard to process PDF files? I thought you said it wasn't.

But okay, if you /think/ it's different, just show me a cat for PDF.
Presumably that's easy too, right?

Actually, its not all that hard.

system("pdftote xt file.pdf");
system("cat file.txt");

Smile. It's supposed to be funny.


Oh, it is. Highly amusing, in fact. Have the film rights gone?


Not yet. You know how to reach me if you're interested. As an added
incentive, I promise to try not to deliver the script to you in PDF format.
Seriously though, there is a utility
called pdftotext. It doesn't really do a great job in terms of rendering
readable text from pdf, but for purposes of solving the proposed
exercise, it should be enough to use this and pipe the output through
your standard C solution for text files :-)


No, not really. The output from pdftotext sucks. It's certainly not good
enough for comp.lang.c, IMHO. Furthermore, the availability of pdftotext
and cat is not guaranteed by ISO C, so your system() calls might fail to
do what is expected of them.


Wot eez deez PDF in ISO C? Sorry, I'll stop now. ;-)

-nrk.
--
Remove devnull for email
Nov 14 '05 #135
On Sun, 15 Feb 2004 07:25:02 +0000 (UTC), in comp.lang.c , Richard
Heathfield <do******@addre ss.co.uk.invali d> wrote:
Mark McIntyre wrote:
No, thats just my hourly rate for answering homework questions.
This isn't homework. You made a claim, and now you refuse to back it up. I
conclude that the claim is insupportable. If you think I'm wrong, *prove*
it.


Richard, I'm not playing this game with you any longer. Its patently
obvious that to write a PDF interpreter in standard C is not a hard task. I
don't have to prove anything and I suspect that most regulars here could do
it standing on their heads. If you can't (and I'm quite sure you can) then
thats surprising.
Golly, prove that you can convert uppercase characters in a stream of data
into lowercase ones using only standard C? oooo thats tricky....


Learn To Read. Then Turn To Page 24 Of K&R2, And Read Exercise 1-13.


Learn to Understand. In my copy of K&R, page 24 begins:
"caller, as does "falling off the end" of a fucntion by reaching the
terminating right brace.
Exercise 1-13. Write a program to convert..."
Note also that you are /not/ using a normal data stream, but a PDF file.
And a PDF file is not a data stream because ?
is your program's job to interpret that file correctly so that the purposes
of the exercise are correctly satisfied.
I can satisfy the requrements of the exercise correctly with /any/
datastream. Data is data.
You asked me to solve K&R2 1.13. Now in my copy thats
"write a program to convert its input to lower case, using a function
lower(c) which returns c if c is not a letter, and the lower case value of
c if it is a letter"


Then get a book that has the same 1.13 as everyone else's 1.13.


Why? If you don't make it clear what you want thats hardly my problem.
The point, which you appear to have failed to grasp, is that text processing
in C is *easy*. You have claimed that PDF processing is easy, too, but you
apparently can't even solve a simple exercise using PDF input.
Richad, I'm well used to watching you manipulate other's posts to your own
advantage, so its pointless trying it on me. I #can# do this. I choose not
to because I don't propose to pander to your childishness.
Just as a reminder, here is what you claimed: "Its also easy to write tex to
dvi to pcl processors in standard C. Its also easy to write pdf readers in
standard C."

I remain unconvinced.
Thats tough.


--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.c om/ms3/bchambless0/welcome_to_clc. html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 14 '05 #136
On Sun, 15 Feb 2004 07:29:16 +0000 (UTC), in comp.lang.c , Richard
Heathfield <do******@addre ss.co.uk.invali d> wrote:
Mark McIntyre wrote:
Richard. Read back through my posts. See if you can spot where I said I
intended to convert the pdf into cutsey graphical output...
I don't have to. You claimed PDF processing is easy, but you appear to be
incapable of supporting your claim.


As I've said elsethread, thats a false assertion. I have watched you do
this before with other people, and found it disturbing. Report the facts,
not your twist on them to suit your desire to win the point.

Here's my position. I claim that its easy to /write/ a pdf processor in
standard C. I don't propose to post teh code here because its too long, and
frankly unnecesary. I don't claim that the program will be simple.
my proposed
reader does nothing more sophisticated than determine the words in the
pdf, and print them to stdout.


In other words, you appear to be claiming now that PDF processing is so
difficult that the only way you can realistically use PDF data is to turn
it to text data first,


Now you're beginning to annoy me. You lie with the above remark. What I'm
saying and I believe you understand that, is that using only Standard C,
its clearly not possible to generate graphical output. Therefore I won't do
it.
The obvious strategy, then, is to store the data in text
format to begin with, thus neatly cutting out the middle man.


I'm not converting it into a text file. What gives you that bizarre
impression?
I'm sorry, I've been taking the p*ss.


If you must do that, please learn how to do it properly.


I'll be more obvious next time. When you get a sense of humour and less of
a sense of self-importance, let me know.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.c om/ms3/bchambless0/welcome_to_clc. html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 14 '05 #137
In article <c0**********@h ercules.btinter net.com>,
do******@addres s.co.uk.invalid says...
You asked me to solve K&R2 1.13. Now in my copy thats
"write a program to convert its input to lower case, using a function
lower(c) which returns c if c is not a letter, and the lower case value of
c if it is a letter"


Then get a book that has the same 1.13 as everyone else's 1.13.


It's clear that he's using K&R1, despite writing K&R2 above.
--
Randy Howard
2reply remove FOOBAR

Nov 14 '05 #138
In article <t5************ *************** *****@4ax.com>,
ma**********@sp amcop.net says...
Golly, prove that you can convert uppercase characters in a stream of data
into lowercase ones using only standard C? oooo thats tricky....


Learn To Read. Then Turn To Page 24 Of K&R2, And Read Exercise 1-13.


Learn to Understand. In my copy of K&R, page 24 begins:
"caller, as does "falling off the end" of a fucntion by reaching the
terminating right brace.
Exercise 1-13. Write a program to convert..."


Clearly, you made a mistake the first time, and used K&R1, even though
you yourself mentioned K&R2 previously. If we read a little further along,
it's conveniently located in your quoted text below:
You asked me to solve K&R2 1.13. Now in my copy thats
"write a program to convert its input to lower case, using a function
lower(c) which returns c if c is not a letter, and the lower case value of
c if it is a letter"

Then get a book that has the same 1.13 as everyone else's 1.13.


Why? If you don't make it clear what you want thats hardly my problem.


Not only did he make it clear, you did as well, you just opened the
wrong version of the book. Right?

I'm not disagreeing with your arguments btw, I just don't see any
reason to try and cover up such a simple mistake.

--
Randy Howard
2reply remove FOOBAR

Nov 14 '05 #139
Dan Pop <Da*****@cern.c h> scribbled the following:
The 1 to 1 correspondence between what you see on the screen and what you
get printed is a big bonus when selectively printing parts of the
document, which is what I often do. And high resolution screens are
commonly available these days (1050x1400 for laptops, 1200x1600 for
desktops) for people who want to enjoy the quality of a good PDF
renderer. Last but not least, having the complete document, which can be a thick
book, in a single file of reasonable size is extremely convenient. I don't like PDF for documents where plain text would do equally well,
like most of the C standard. But once multiple fonts are a *real* need,
as well as pictures and complex diagrams, not to mention *proper* support
for languages other than English and whatever can fit into Latin-1, I have
yet to see something better than PDF.


I agree with you, and may I add that one other reason for preferring
PDFs is that they're easy to generate from PostScript documents, which
can be made to include mathematical symbols not found in pretty much
any ISO-8859-x character set, by using LaTeX. I have found this a very
good thing when writing homework solutions in mathematics.

--
/-- Joona Palaste (pa*****@cc.hel sinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"You will be given the plague."
- Montgomery Burns
Nov 14 '05 #140

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

Similar topics

1
2935
by: Rhino | last post by:
Can anyone point me to a good free XSLT Tutorial online? I looked for some a few months ago and didn't find anything very good. I'm hoping some of the experts here can point me to a good XSLT tutorial..... -- Rhino --- rhino1 AT sympatico DOT ca "There are two ways of constructing a software design. One way is to make it
15
4243
by: binnyva | last post by:
Hello Everyone, I have just compleated a JavaScript tutorial and publishing the draft(or the beta version, as I like to call it) for review. This is not open to public yet. The Tutorial is avaliable at... http://www.geocities.com/binnyva/code/javascript/advanced_tutorial/ If any of you could spare the time, please have a look at my tutorial
18
1969
by: Xah Lee | last post by:
i've started to read python tutorial recently. http://python.org/doc/2.3.4/tut/tut.html Here are some quick critique: quick example: If the input string is too long, they don't truncate it, but return it unchanged; this will mess up your column lay-out but that's usually better than the alternative, which would be lying about a value. (If you really want truncation you can always add a slice operation, as in
0
1788
by: Joe Mayo | last post by:
I've recently updated the C# Tutorial at C# Station with a new addition, Lesson 17: Enums. The C# Tutorial may be found at http://www.csharp-station.com/Tutorial.aspx. Other updates include: 1. Downloadable source code. 2. All example programs run on-line as NTD apps. 3. A support forum for discussing the Tutorial.
10
3096
by: Safalra | last post by:
When a poster in a forum I frequent said they were beginning to learn HTML, I thought I should direct them to a good HTML tutorial so that they wouldn't start using <blink> and the like. Remembering that this group has discussed HTML tutorials several times in the past, I searched the Google Groups archives, but all I can find are tutorials unfortunately demonstrating Flavell's Law. Searching the internet, the only accurate tutorials for...
11
2944
by: Magnus Lycka | last post by:
While the official Python Tutorial has served its purpose well, keeping it up to date is hardly anyones top priority, and there are others who passionately create really good Python tutorials on the web. I think 'A Byte of Python' by Swaroop C H is a good beginners tutorial, and 'Dive Into Python' by Mark Pilgrim is a good tutorial for more experienced programmers.
7
2261
by: Turbo | last post by:
I have a written a detailed html tutorial here:- http://sandy007smarty.seo.iitm.ac.in/2006/09/26/html-tutorial/ I know there are a couple of html tutorials out there. But its a tutorial without links!! Everything in one page. Please leave a comment if you like it.
2
2113
by: sara | last post by:
Hi All, I learned C++ long time ago and now I want to review all of its details in a short time like a week. I wonder if there is a good tutorial you know which I can read for this purpose. Thanks a lot.
0
9903
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9754
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
10692
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...
1
10767
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7084
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5754
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
5952
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4567
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
4168
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.