* what do the dots mean?
@ 2005-09-04 20:55 _z33
2005-09-04 12:05 ` sumit kalra
0 siblings, 1 reply; 6+ messages in thread
From: _z33 @ 2005-09-04 20:55 UTC (permalink / raw)
To: linux-newbie
I'm not able to understand the usage of dots (inside the printf's
arguments) in the following code. Please enlighten me!
[code]
#include <stdio.h>
#include <time.h>
main()
{
time_t now;
time(&now);
printf("It's %.24s.\n", ctime(&now));
system ("PAUSE");
return 0;
}
[/code]
_z33
--
I love TUX; well... that's an understatement :)
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: what do the dots mean?
2005-09-04 20:55 what do the dots mean? _z33
@ 2005-09-04 12:05 ` sumit kalra
2005-09-05 0:45 ` _z33
0 siblings, 1 reply; 6+ messages in thread
From: sumit kalra @ 2005-09-04 12:05 UTC (permalink / raw)
To: _z33, linux-newbie
Well, the first dot along with the 24 (%.24s)
specifies to printf to print only 24 characters of the
string.
Second dot is a full stop after the string. :-)
-Sumit
--- _z33 <timid.Gentoo@gmail.com> wrote:
> I'm not able to understand the usage of dots (inside
> the printf's
> arguments) in the following code. Please enlighten
> me!
>
> [code]
> #include <stdio.h>
> #include <time.h>
>
> main()
> {
> time_t now;
>
> time(&now);
> printf("It's %.24s.\n", ctime(&now));
>
> system ("PAUSE");
> return 0;
> }
> [/code]
>
> _z33
> --
> I love TUX; well... that's an understatement :)
>
> -
> To unsubscribe from this list: send the line
> "unsubscribe linux-newbie" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at
> http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at
> http://www.linux-learn.org/faqs
>
___________________________________________________________
Does your mail provider give you FREE antivirus protection?
Get Yahoo! Mail http://uk.mail.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: what do the dots mean?
2005-09-04 12:05 ` sumit kalra
@ 2005-09-05 0:45 ` _z33
2005-09-04 13:10 ` sumit kalra
2005-09-05 16:04 ` Stephen Samuel
0 siblings, 2 replies; 6+ messages in thread
From: _z33 @ 2005-09-05 0:45 UTC (permalink / raw)
To: linux-newbie
sumit kalra wrote:
> Well, the first dot along with the 24 (%.24s)
> specifies to printf to print only 24 characters of the
> string.
>
> Second dot is a full stop after the string. :-)
>
Thanks for the info.
But in that case when you remove the first dot you should be able to see
the second dot for sure, right? But the moment I remove the first dot,
the second dot disappears from the output.
_z33
--
I love TUX; well... that's an understatement :)
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: what do the dots mean?
2005-09-05 0:45 ` _z33
@ 2005-09-04 13:10 ` sumit kalra
2005-09-05 16:04 ` Stephen Samuel
1 sibling, 0 replies; 6+ messages in thread
From: sumit kalra @ 2005-09-04 13:10 UTC (permalink / raw)
To: _z33, linux-newbie
I am not sure why you are not seeing the last dot.
Okay, so when you remove the first dot, printf prints
the complete string which would have a newline
character (\n) as it's 25th element so the dot should
appear on the next line.
-Sumit
--- _z33 <timid.Gentoo@gmail.com> wrote:
> sumit kalra wrote:
> > Well, the first dot along with the 24 (%.24s)
> > specifies to printf to print only 24 characters of
> the
> > string.
> >
> > Second dot is a full stop after the string. :-)
> >
>
> Thanks for the info.
>
> But in that case when you remove the first dot you
> should be able to see
> the second dot for sure, right? But the moment I
> remove the first dot,
> the second dot disappears from the output.
>
>
> _z33
> --
> I love TUX; well... that's an understatement :)
>
> -
> To unsubscribe from this list: send the line
> "unsubscribe linux-newbie" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at
> http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at
> http://www.linux-learn.org/faqs
>
___________________________________________________________
How much free photo storage do you get? Store your holiday
snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: what do the dots mean?
2005-09-05 0:45 ` _z33
2005-09-04 13:10 ` sumit kalra
@ 2005-09-05 16:04 ` Stephen Samuel
2005-09-06 16:51 ` _z33
1 sibling, 1 reply; 6+ messages in thread
From: Stephen Samuel @ 2005-09-05 16:04 UTC (permalink / raw)
To: _z33; +Cc: linux-newbie
No the second dot does NOT disappear... Watch your output closely.
You should also get yourself a linux distribution ( www.knoppix.org
has bootable CD or DVD images ). and try the command 'man ctime'
(the reason why I say that is that is that 'PAUSE' is a DOS command)
The %.24s says "Only print the first 24 characters of the output
from 'ctime'. You see, the output from ctime includes a newline as
the last (25th) character of it's output, so %.24s chops off the output
just before the newline.
I.e. the resultint output is <DATE>\n.\n
The trailing dot is now on the next line.
_z33 wrote:
> sumit kalra wrote:
>
>> Well, the first dot along with the 24 (%.24s) specifies to printf to
>> print only 24 characters of the
>> string.
>>
>> Second dot is a full stop after the string. :-)
>>
>
> Thanks for the info.
>
> But in that case when you remove the first dot you should be able to
> see the second dot for sure, right? But the moment I remove the first
> dot, the second dot disappears from the output.
printf("It's %.24s.\n", ctime(&now));
system ("PAUSE");
--
Stephen Samuel +1(604)876-0426 samuel@bcgreen.com
http://www.bcgreen.com/~samuel/
Powerful committed communication. Transformation touching
the jewel within each person and bringing it to light.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: what do the dots mean?
2005-09-05 16:04 ` Stephen Samuel
@ 2005-09-06 16:51 ` _z33
0 siblings, 0 replies; 6+ messages in thread
From: _z33 @ 2005-09-06 16:51 UTC (permalink / raw)
To: linux-newbie
Stephen Samuel wrote:
> No the second dot does NOT disappear... Watch your output closely.
> You should also get yourself a linux distribution ( www.knoppix.org
> has bootable CD or DVD images ). and try the command 'man ctime'
> (the reason why I say that is that is that 'PAUSE' is a DOS command)
>
> The %.24s says "Only print the first 24 characters of the output
> from 'ctime'. You see, the output from ctime includes a newline as
> the last (25th) character of it's output, so %.24s chops off the output
> just before the newline.
>
> I.e. the resultint output is <DATE>\n.\n
>
> The trailing dot is now on the next line.
Thanks. I saw that :)
_z33
--
I love TUX; well... that's an understatement :)
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-09-06 16:51 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-04 20:55 what do the dots mean? _z33
2005-09-04 12:05 ` sumit kalra
2005-09-05 0:45 ` _z33
2005-09-04 13:10 ` sumit kalra
2005-09-05 16:04 ` Stephen Samuel
2005-09-06 16:51 ` _z33
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox