Skip to content

Commit c7a0195

Browse files
committed
add time.c and some formatting of readmes
1 parent f3b3c23 commit c7a0195

File tree

4 files changed

+45
-14
lines changed

4 files changed

+45
-14
lines changed

c/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
Code snippets for C.
44

5+
## notes
6+
7+
Build with:
8+
```
9+
gcc <file>.c -std=c99 -o <file>.out
10+
```
11+
512

613
## todo
714

c/time.c

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <stdio.h>
2+
#include <time.h>
3+
4+
// retrieve current time
5+
// format as string
6+
// write to standard output
7+
8+
int main()
9+
{
10+
time_t now;
11+
struct tm *ts;
12+
char buf[80];
13+
14+
// get current time
15+
now = time(NULL);
16+
17+
// format and print the time
18+
// "ddd yyyy-mm-dd hh:mm:ss zzz"
19+
ts = localtime(&now);
20+
strftime(buf, sizeof(buf), "%a %Y-%d-%d %H:%M:%S %Z", ts);
21+
puts(buf);
22+
23+
return 0;
24+
}

go/modules.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,39 @@
22

33
### create new module
44

5-
Make the current directory the root of a module
5+
Make the current directory the root of a module:
66
```
77
go mod init example.com/hello
88
```
99

10-
List the current module and all its dependencies
10+
List the current module and all its dependencies:
1111
```
1212
go list -m all
1313
```
1414

1515
### module management
1616

17-
Get a specific module version
17+
Get a specific module version:
1818
```
1919
go get example.com/[email protected]
2020
```
2121

22-
Get a branch
22+
Get a branch:
2323
```
2424
go get example.com/hello@<branch-name>
2525
```
2626

27-
Get a commit
27+
Get a commit:
2828
```
2929
go get example.com/hello@<commit>
3030
```
3131

32-
Add missing and remove unused modules
32+
Add missing and remove unused modules:
3333
```
3434
go mod tidy
3535
```
3636

37-
Explain why packages or modules are needed
37+
Explain why packages or modules are needed:
3838
```
3939
go mod why -m <module-path>
4040
```
@@ -48,12 +48,12 @@ Ref: [Defining Go Modules (Go & Versioning, Part 6)](https://research.swtch.com/
4848

4949
#### usage
5050

51-
Make a vendored copy of dependencies
51+
Make a vendored copy of dependencies:
5252
```
5353
go mod vendor
5454
```
5555

56-
Build dependencies from the vendor directory
56+
Build dependencies from the vendor directory:
5757
```
5858
go build -mod vendor
5959
```

nmap.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
## usage examples
44

5-
The following examples assume a target of `192.168.0.0/24`.
6-
5+
Flag to set timing template (higher is faster):
76
```
8-
-T<0-5>: Set timing template (higher is faster)
7+
-T<0-5>
98
```
109

1110
### OS scan
12-
Determine OS of hosts.
11+
12+
Determine OS of hosts:
1313
```
1414
nmap -O 192.168.0.0/24
1515
```
1616

1717
### ping scan
18-
Determine hosts reachable via ping.
1918

19+
Determine hosts reachable via ping:
2020
```
2121
nmap -sn 192.168.0.0/24
2222
```

0 commit comments

Comments
 (0)