How big is the argv[] array?

Ron Natalie ron at ron.rutgers.edu
Wed Oct 5 01:12:38 AEST 1988


Your code will work, albeit a pretty raunchy way of doing things.
Assigning into the argc'th position is safe since it is allocated
(it holds that null, -1 if you're really living in the past).
You just have to be careful that nothing later on is going to check
to see if that null was there (like you pass the whole kit and
kaboodle to execv or something).  Perhaps I can suggest an
alternative:

main(argc, argv)
	int	argc;
	char	**argv;
{
	if(argc == 1)
		process_arg(DEFAULT_ARG);
	else
		while(--argc)
			processs_arg(++argv);
}

Almost anything you can kludge, you can spend a minute to do right.

-Ron



More information about the Comp.lang.c mailing list