aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Strapp <msattr@gmail.com>2020-10-12 08:16:48 -0500
committerMatthew Strapp <msattr@gmail.com>2020-10-12 08:16:48 -0500
commit334fd25273d5a45f4e8254e65e18b2124dae94d5 (patch)
treedb498174180fd346f54599715814f3e9846edc31
parentadd broken old breakout (diff)
downloadhomework-334fd25273d5a45f4e8254e65e18b2124dae94d5.tar
homework-334fd25273d5a45f4e8254e65e18b2124dae94d5.tar.gz
homework-334fd25273d5a45f4e8254e65e18b2124dae94d5.tar.bz2
homework-334fd25273d5a45f4e8254e65e18b2124dae94d5.tar.lz
homework-334fd25273d5a45f4e8254e65e18b2124dae94d5.tar.xz
homework-334fd25273d5a45f4e8254e65e18b2124dae94d5.tar.zst
homework-334fd25273d5a45f4e8254e65e18b2124dae94d5.zip
add new breakout
Diffstat (limited to '')
-rw-r--r--.vscode/c_cpp_properties.json4
-rw-r--r--csci4061/101220_breakout/exercise.c38
2 files changed, 40 insertions, 2 deletions
diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
index a308c92..c80bfaa 100644
--- a/.vscode/c_cpp_properties.json
+++ b/.vscode/c_cpp_properties.json
@@ -3,12 +3,12 @@
{
"name": "Linux",
"intelliSenseMode": "gcc-x64",
- "compilerPath": "/usr/bin/g++",
+ "compilerPath": "/usr/bin/gcc",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
- "cStandard": "c11",
+ "cStandard": "c18",
"cppStandard": "c++20"
}
],
diff --git a/csci4061/101220_breakout/exercise.c b/csci4061/101220_breakout/exercise.c
new file mode 100644
index 0000000..5021142
--- /dev/null
+++ b/csci4061/101220_breakout/exercise.c
@@ -0,0 +1,38 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <string.h>
+
+int numOfEntries(char* path) {
+ /*
+ Count the number of entries in path
+ */
+}
+
+int main(int argc, char** argv){
+ if (argc < 2) {
+ printf("Pass the path as an argument to the program");
+ exit(1);
+ }
+ char* path = argv[1];
+
+ DIR* dir = opendir(path);
+ if(dir==NULL){
+ printf("The path passed is invalid");
+ return -1;
+ }
+ struct dirent* entry;
+
+ /*
+ Iterate through the elements in argv[1]
+ Refer the ls example in slides if you have any doubts
+ */
+
+ closedir(dir);
+ return 0;
+} \ No newline at end of file