Code: #include <stdio.h>
#include <stdlib.h>
#include <ti/screen.h>
#include <ti/getcsc.h>
int main(int argc, char **argv) {
os_ClrHome();
os_HomeUp();
if (argc != 2) {
os_PutStrFull("Err: Args");
while (!os_GetCSC());
return 1;
}
os_PutStrFull("MAIN:"); os_NewLine();
printf(" LD HL,%d\n", atoi(argv[1]));
os_PutStrFull(" RET"); os_NewLine();
while (!os_GetCSC());
return 0;
}
When I run prgmCECC without any args and it dosen't give any errors but too many args and there is an error.
Why? What's wrong?
Thanks.
Have you made sure to hit a key? You have a while(!os_GetCSC()); block, so you need to hit a key.
I am saying if I don't give the program any args then the if statement dosen't run for some reason. Idk how the os_GetCSC would affect that.
Edit: Either, 1) Yesterday me at 10 pm was insane, or 2) Huh , what the flippady just happend.
I added a printf("%d\n\n"); before the if.Now it always works?
Edit 2: I tested the original program and it works. But I tested the program yesterday and it didn't.?????
Am I crazy?
Maybe this is an error in the CE C compiler or something, I don't really understand C that deep, but I'm pretty sure the program defaults to 1 or something if no args are passed(?).
Also, here's an attempt at fixing the if statement:
Code:
if (argc < 2) {
os_PutStrFull("Err: Need Args");
while (!os_GetCSC());
return 1;
}
I don't know if this will work or is what you intended, but maybe try it? (the args might pass in a different way than you want though)
Are you able to provide your test inputs?
Assuming you are putting your args into a string in Ans before running your program?
Unfortunately I forgot them. Sorry. But also apparently the original code works. I really don't know what happend to my brain that day but yeah.
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
»
Go to Registration page
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum