This has been bugging me since I found this out few months ago... (Don't know if this is specific to DOS/DJGPP). Anyway, how to get it as '*' to the program?
This has been bugging me since I found this out few months ago... (Don't know if this is specific to DOS/DJGPP). Anyway, how to get it as '*' to the program?
kooma - [email protected]
Post a short program that has the problem and I'll compile it with MS and see if it is compiler specific.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
Well, at least on Unix systems, '*' etc. are handled by the shell. To prevent interpretation of them you could use quotes ('*' or "*"), or escape them with a backslash (\*).
> To prevent interpretation of them you could use quotes ('*' or "*"), or escape them with a backslash (\*).
What if I want to write a dir-program (my attempt before figuring this one...)
And here's for adrianxw: run it with '*' as an argument (not those 's) and get a directory listing.
Code:#include <stdio.h> int main(int argc, char **argv) { for(int i = 0; i < argc; i++) printf("%s\n", argv[i]); return 0; }
Prints an asterisk. MS VC++ 6.0, Windows 2000.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
You have to understand that the * is handled by the shell, and hence while using MS VC++, the * is passed to the program as it is (the shell doesn't handle it there).
While with DOS or Unix terminals, you can use "*" quotes to put the * as it is (this is defined by the shells, so you have to comply with their instructions...there's nothing wrong with the program).
It's all explained in the DJGPP FAQ
http://www.delorie.com/djgpp/v2faq/faq16.html