We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 51569ab commit cb4e421Copy full SHA for cb4e421
0x0F-function_pointers/100-main_opcodes.c
@@ -0,0 +1,42 @@
1
+#include <stdio.h>
2
+#include <stdlib.h>
3
+
4
+/**
5
+ * error - prints error message and exits
6
+ *
7
+ * @err: error code
8
+ */
9
+void error(int err)
10
+{
11
+ printf("Error\n");
12
+ exit(err);
13
+}
14
15
16
+ * main - prints the opcodes of its own main function.
17
18
+ * @argc: number of arguments
19
+ * @argv: array of arguments
20
21
+ * Return: 0
22
23
+int main(int argc, char *argv[])
24
25
+ int i, n;
26
27
+ if (argc != 2)
28
+ error(1);
29
30
+ n = atoi(argv[1]);
31
+ if (n < 0)
32
+ error(2);
33
34
+ for (i = 0; i < n; i++)
35
+ {
36
+ printf("%02hhx", ((char *)main)[i]);
37
+ if (i < n - 1)
38
+ printf(" ");
39
+ }
40
+ printf("\n");
41
+ return (0);
42
0x0F-function_pointers/main
16.5 KB
0 commit comments