Re: read writte to file
- From: pete <pfiland@xxxxxxxxxxxxxx>
- Date: Wed, 08 Jun 2005 10:42:33 GMT
Carramba wrote:
>
> oh man thats rocks! thanx,
> I jus have few questions and I hope you don't
> mind to answer them
>
> On Tue, 07 Jun 2005 23:04:11 +0200,
> pete <pfiland@xxxxxxxxxxxxxx> wrote:
> > int cK, rc;
> > cK = getchar();
> > getchar();
> why do you double getchar(); ?
To eat the '\n' from the Enter key.
Note that cK is of type int and not char,
to match the return type of getchar.
> > fputs("Type a name: ", stdout);
> > fflush(stdout);
> > rc = scanf("%" xstr(a_LEN) "[^\n]%*[^\n]", a_Namn);
>
> don't realy understand what are you doing here
> ( in line above )? I se
> that you are reading input, but could you explaine more?
Zorna Cutura explained it pretty good.
The idea, is to convert text lines into strings.
Text files and streams are made of lines.
A line is like a string, except that a line is
teminated by a '\n' character,
and a string is terminated by a '\0' character.
> > if (!feof(stdin)) {
> > getchar();
> > }
> > if (rc != 1) {
> > *a_Namn = '\0';
> > }
> > fputs("Type cd titel: ", stdout);
There should be
fflush(stdout);
after that fputs.
--
pete
.
- Follow-Ups:
- Re: read writte to file
- From: pete
- Re: read writte to file
- References:
- read writte to file
- From: Carramba
- Re: read writte to file
- From: pete
- Re: read writte to file
- From: Carramba
- read writte to file
- Prev by Date: Re: What declarations of main exist in the c standard?
- Next by Date: Re: is variant-length array declaration standard compatible?
- Previous by thread: Re: read writte to file
- Next by thread: Re: read writte to file
- Index(es):
Relevant Pages
|
Loading