I want to use the system function to get the number of accounts on windows and on linux. I have no idea where to look. Please just point me in the right direction.
See Question&Answers more detail:osI want to use the system function to get the number of accounts on windows and on linux. I have no idea where to look. Please just point me in the right direction.
See Question&Answers more detail:osThe system()
function runs a program. If you know a command line that does what you need, you can use system()
to run that command line.
I'm not sure what command-line program would give the number of accounts on Windows. You could get an approximation by looking at the number of home directories. On Windows the home directories are in Users
and on Linux home directories are in `/home'.
The system()
function doesn't capture the output of the program. You would then likely need to run a command line that redirects the program output to a file, then open this file and parse the output.
You would probably have an easier time solving this problem using a language like Python. Python programs are very portable and there are some wrappers for system stuff.
Good luck.