Skip to content

Commit

Permalink
Update C/EnvVars/README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
sheisc committed Jun 7, 2024
1 parent ffc3d03 commit 221ba03
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions C/EnvVars/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,37 @@ int main(int argc, char **argv, char **env) {
```
## 5 A similar test case in [our large assignment](../../LargeAssignment/tests/EnvVars.scc)
The following test case is not written in C, but with a simple language defined in our large assignment.
You can see how low-level pointer arithmetic (e.g., SccRead64()) is used in [accessing memory](../../C/AccessMemory/README.md).
```C
// COMP9024/LargeAssignment/tests/EnvVars.scc
printStrs(strs){
long i;
long s;
i = 0;
s = SccRead64(strs, i*8);
while(s){
puts(s);
i = i + 1;
s = SccRead64(strs, i*8);
}
}
main(argc, argv, env){
output(argc);
// Display command-line arguments
printStrs(argv);
// '\n'
putchar(10);
// Display environment variables
printStrs(env);
return 0;
}
```

0 comments on commit 221ba03

Please sign in to comment.