define arguments for todos

This commit is contained in:
talksik
2025-08-03 16:03:42 -07:00
commit a423d52d96
2 changed files with 42 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
CC = gcc
CFLAGS = -Wall -g -Iinclude
TARGET = main
SRC = main.c
LIBS = -lcurl
$(TARGET): $(SRC)
$(CC) $(CFLAGS) -o $(TARGET) $(SRC) $(LIBS)
clean:
rm -f *.o $(TARGET)
+31
View File
@@ -0,0 +1,31 @@
#include <stdio.h>
struct data_t {};
void print_help() {
printf("Here is the help manual: \n"
"-c <todo_name> | create a todo\n"
"-l | list all todos\n"
"-d | delete a particular todo\n");
}
int main(int argc, char *argv[]) {
printf("Hello world \n");
printf("Received %d arguments\n", argc);
if (argc < 1) {
print_help();
}
for (int i = 0; i < argc; i++) {
printf("Argument: %s\n", argv[i]);
}
int read = 0;
char **moving_ptr = argv;
while (read < argc) { // 0 < 2, 0 < 1
printf("Argument (ptr loop method): %s\n", *moving_ptr);
moving_ptr = moving_ptr + 1;
read++;
}
}