Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DUMONT Axel
Project
Commits
2f1deb08
Commit
2f1deb08
authored
3 months ago
by
DUMONT Axel
Browse files
Options
Downloads
Patches
Plain Diff
ajout de sf1b
parent
94fa9584
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
sf1b
+0
-0
0 additions, 0 deletions
sf1b
sf1b.c
+47
-0
47 additions, 0 deletions
sf1b.c
sf1b.o
+0
-0
0 additions, 0 deletions
sf1b.o
with
47 additions
and
0 deletions
sf1b
0 → 100755
+
0
−
0
View file @
2f1deb08
File added
This diff is collapsed.
Click to expand it.
sf1b.c
0 → 100644
+
47
−
0
View file @
2f1deb08
#include
<stdio.h>
#include
<stdlib.h>
#include
<time.h>
// Print the current date and time in C
int
main
(
void
)
{
// variables to store the date and time components
int
hours
,
minutes
,
seconds
,
day
,
month
,
year
;
// `time_t` is an arithmetic time type
time_t
now
;
// Obtain current time
// `time()` returns the current time of the system as a `time_t` value
time
(
&
now
);
// Convert to local time format and print to stdout
printf
(
"Today is %s"
,
ctime
(
&
now
));
// localtime converts a `time_t` value to calendar time and
// returns a pointer to a `tm` structure with its members
// filled with the corresponding values
struct
tm
*
local
=
localtime
(
&
now
);
hours
=
local
->
tm_hour
;
// get hours since midnight (0-23)
minutes
=
local
->
tm_min
;
// get minutes passed after the hour (0-59)
seconds
=
local
->
tm_sec
;
// get seconds passed after a minute (0-59)
day
=
local
->
tm_mday
;
// get day of month (1 to 31)
month
=
local
->
tm_mon
+
1
;
// get month of year (0 to 11)
year
=
local
->
tm_year
+
1900
;
// get year since 1900
// print local time
if
(
hours
<
12
)
{
// before midday
printf
(
"Time is %02d:%02d:%02d am
\n
"
,
hours
,
minutes
,
seconds
);
}
else
{
// after midday
printf
(
"Time is %02d:%02d:%02d pm
\n
"
,
hours
-
12
,
minutes
,
seconds
);
}
// print the current date
printf
(
"Date is: %02d/%02d/%d
\n
"
,
day
,
month
,
year
);
return
0
;
}
This diff is collapsed.
Click to expand it.
sf1b.o
0 → 100644
+
0
−
0
View file @
2f1deb08
File added
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment