Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tranquility Virtual Machine
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
Container 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
Vishnu Menon
Tranquility Virtual Machine
Commits
0d5236a4
Commit
0d5236a4
authored
1 year ago
by
Vishnu Menon
Browse files
Options
Downloads
Patches
Plain Diff
read file provided via argument
parent
c34e8c08
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+2
-1
2 additions, 1 deletion
.gitignore
src/main.c
+36
-3
36 additions, 3 deletions
src/main.c
with
38 additions
and
4 deletions
.gitignore
+
2
−
1
View file @
0d5236a4
build/
tmp/
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main.c
+
36
−
3
View file @
0d5236a4
#include
<stdio.h>
int
main
(
void
)
// my everlasting commitment to ridding code of magic numbers :)
#define MEMORY_SIZE 65535
#define BUFFER_SIZE 32767
int
memory
[
MEMORY_SIZE
];
// no idea what these are yet, when i figure that out i'll rename them something better
int
sp
,
fp
=
MEMORY_SIZE
;
int
img
,
but
,
lab
,
tab
=
0
;
// renaming these too
int
main
(
int
argc
,
char
*
argv
[])
{
printf
(
"Hello world!
\n
"
);
if
(
argc
<
2
)
{
printf
(
"Error: Did not specify file."
);
return
1
;
}
else
if
(
argc
>
2
)
{
printf
(
"Error: Too many arguments!"
);
return
1
;
}
FILE
*
executable
=
fopen
(
argv
[
1
],
"r"
);
if
(
executable
==
NULL
)
{
printf
(
"Error: Could not locate %s"
,
argv
[
1
]);
return
1
;
}
char
buffer
[
BUFFER_SIZE
];
while
(
fgets
(
buffer
,
BUFFER_SIZE
-
1
,
executable
)
!=
NULL
)
{
printf
(
"%s"
,
buffer
);
}
return
0
;
}
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