main()

D

Default User

Bill said:
Then explain why you, after all this time, are unable to look at the
signature of function and give it the correct type arguments? I mean,
argc as the first argument to sscanf()? Not to mention trying to read
INTO argv[1]?
I've never come across a decent C tutorial. K&r2 isn't it. Besides I
can't remember the day sometimes, let alone function parameters.

You open K&R, you go to Appendix B (Standard Library) and look at
section B.1.3 (Formatted Input) where you find:

int sscanf(const char *s, const char *format, ...)
sscanf(s, ...) is equivalent to scanf(...) except that the input
characters are taken from the string s.

You can also refer to section 7.4 of the main text, where they have an
extensive explanation of scanf().
That's why
I take aricept. I don't have alzheimers but my thinking processes are
confused by dysthymia and Major depressive disorders.

If you are truely handicapped, I don't want to pick on you, but this
whole thing just seems funky to me.
I have the intellect. But my learning is hindered. And I've always used
vod as the only parameter to main, up til now.

Section 5.10 has a very good explanation of how command-line arguments
work including a nice diagram of the argv[] array and several examples
of how to use the values.

I find it hard to believe that you could look at K&R and get nothing
from it. The going may be slow at first, but the information is there
and in a well-presented manner. Reading each chapter and working the
problems should get you going.




Brian Rodenborn
 
B

Bill Cunningham

I find it hard to believe that you could look at K&R and get nothing
from it. The going may be slow at first, but the information is there
and in a well-presented manner. Reading each chapter and working the
problems should get you going.

It's not that I look at k&r2 and get nothing. I have learned from the
chapters. It's the appendices that really give me trouble. For example,
there's no tutorial on file streams in k&r2 (it's been a while since I
looked at my copy) FILE* it's talked about in the appendices but there's no
examples on how one would use it. Only the parameters for fopen() for
example are talked about. I'm just not good enough to read the prototypes
yet.

This is why I seldom respond to flames. You get nothing, learn nothing,
and everyone thinks you're putting them on.
 
D

Default User

Bill said:
It's not that I look at k&r2 and get nothing. I have learned from the
chapters. It's the appendices that really give me trouble. For example,
there's no tutorial on file streams in k&r2 (it's been a while since I
looked at my copy) FILE* it's talked about in the appendices but there's no
examples on how one would use it.

This isn't true. File streams are covered in Chapter 7 - Input and
Output. There they cover character at a time and line file access. They
don't seem to have covered fread() and fwrite() though.
Only the parameters for fopen() for
example are talked about. I'm just not good enough to read the prototypes
yet.

What else did you want them to say about fopen()? It explains that fopen
makes a file available for access, it returns a FILE* and tells you that
the user needn't worry about the details of FILE. It shows the signature
of fopen() and explains what the two parameters do. After some
discussion of IO functions, it presents a complete example of a file
concatenation program using these concepts (plus argc and argv BTW).

Looks good to me.
This is why I seldom respond to flames. You get nothing, learn nothing,
and everyone thinks you're putting them on.

You frustrate us. You ask loads of questions, but seem to make little
progress.



Brian Rodenborn
 
S

Sam Dennis

Bill said:
For example, there's no tutorial on file streams in k&r2

Chapter 7
(Section 7.5 for files, but a stream is a stream is a stream in C.)

That's eighteen pages and nine exercises in my copy; hardly too much to
ask, even though some knowledge of earlier chapters may be necessary.
 
J

Joe Wright

Bill said:
It's not that I look at k&r2 and get nothing. I have learned from the
chapters. It's the appendices that really give me trouble. For example,
there's no tutorial on file streams in k&r2 (it's been a while since I
looked at my copy) FILE* it's talked about in the appendices but there's no
examples on how one would use it. Only the parameters for fopen() for
example are talked about. I'm just not good enough to read the prototypes
yet.

This is why I seldom respond to flames. You get nothing, learn nothing,
and everyone thinks you're putting them on.

Go Bill. Keep trying. Keep asking. Many of us will try to help. I
understand that you have certain difficulties, memory, attention
span, etc. The normal RTFM admonition doesn't work well for you.

What does work?
 
R

Randy Howard

Everyone says "Get k&r2! Get k&r2!" I got k&r2 which isn't a tutorial
I've learned now but more of a reference work. Now that I'm working with
tutorials I'm learning alot more.

I'm glad you told us, because it isn't obvious.
 
A

Allin Cottrell

Dan said:
Then explain why you, after all this time, are unable to look at the
signature of function and give it the correct type arguments? I mean,
argc as the first argument to sscanf()? Not to mention trying to read
INTO argv[1]?

I've never come across a decent C tutorial.


No one has ever managed to write one that could teach C even to an idiot.
So, give up C: you're clearly wasting your time.

Too harsh! Bill Cunningham has said that he has some cognitive
problems. That does not necessarily make him an "idiot". He
won't earn a living as a C programmer, but he may program for
his own use and amusement.

Allin Cottrell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top