Ok it might sounds dumb, but I couldn't figure out a way to pass int/char into this system call
here is how I would like it to work
system ("cal %d %d", month, year);
I expect this will give me the following command on terminal "cal 3 2009
"
and the terminal will show me the calendar of March 2009.
But the compiler is complaining it has too many arguments
any ideas? I need to make this method system ("cal ")
return me a dynamic calendar.
Notes: cal
take the argument cal month year
You need to build the proper command line string, system()
won't do it for you:
char cmd[64];
snprintf(cmd, sizeof cmd, "cal %d %d", month, year);
system(cmd);
The usual caveats about buffer overflow apply, although in this particular case when both arguments are integers you should be fairly safe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With