I’m trying to build a simple todo app without asking for help, but here I am. I’m not sure but i think the problem is in my readOption function. The printMenu function works just fine, I’m try to get it to print something with the switch statement when I type in 1. I’m not looking for someone to complete the program but maybe nudge me in the right direction.
It doesn’t for me. I get error: IvalidCharacter then it lists other errors,
0x7ff7718b7aec in charToDigit (todo_app.exe.obj)
else => return error.InvalidCharacter,
^
0x7ff771883142 in parseWithSign__anon_3548 (todo_app.exe.obj)
const digit = try charToDigit(c, buf_base);
0x7ff7718819c4 in parseUnsigned__anon_3449 (todo_app.exe.obj)
return parseWithSign(T, buf, base, .pos);
^
0x7ff771881621 in readOption (todo_app.exe.obj)
return user_choice;
^
0x7ff771881a5e in main (todo_app.exe.obj)
const option = try readOption();
run todo_app: error: the following command exited with error code 1:
check out args and argsWithAllocator in std.process. when you grab command line arguments you need to use an allocator in windows, which will also work on linux. but if you are only on linux, you can just use std.process.args.
Do you know any other sources that talk about argsWtihAllocator, maybe with examples or something? I’m not really following or understanding it from the standard documentation.
You can find @ratfactor 's explanation here, in particular the example using std.process.argsAlloc. std.process.argsAlloc works basically the same as std.process.args, expect that you have to pass in an allocator along with it and add an additional defer statement defer std.process.argsFree(allocator, args); afterwords to clear the memory. argsAlloc() will work for both Windows and Linux, whereas args() only works for Linux.
Ok thank you, so it matters what system your on when writing, but when you cross compile does that matter still? Like is it best practice to just use the one that works on both?
To answer your question I just sent you a message. Check your inbox on the left pane. So you can follow up with me there if you have any more questions. Since this thread was already solved. I am available on the messages or you can start a new thread if you want.