delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/06/30/00:40:22

Date: Fri, 30 Jun 1995 00:05:39 -0400 (EDT)
From: Mitran/Marcel/Mr <nverever AT wendy DOT ee DOT mcgill DOT ca>
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: if problem

Okay, I wrote a program which takes command line parameters. The program
parses them in the following way:

...
if (*Param == '-')		/*This part checks for a dash*/
{
	Param++;		/*Makes char *Param point to  */
				/*the next character in string */
	switch (*Param){
		...		/*A few cases here, too long to mention */
		case 'p':
			Param++;
			if (*Param == 'a')	/*The first parameter(-pa)*/
				{...}
			if (*Param == 'b')	/*The second parameter(-pb)*/
				{...}
			if (*Param == 'c')	/*The third parameter(-pc) */
				{...}
			break;
	}
}

	Okay, now that is the basic structure of the parser. When I use
-pb or -pc, they execute their specific code, but -pa doesn't work because
it seems like the if is never tested. If I add the exact same code for the
-pa paramter after the test for the -pc parameter while keeping the original
if for the -pa, it works now. However, if I remove the comment:
/*The first parameter */, the -pb if doesn't work anymore.

	I don't think it's normal that where I comment my code should
affect the compiler output. I guess it's true, well commented code
does lead to better programs! Seriously, is this a bug or a programming
error on my part? Am I the only one who has this problem?
 
			Thanks in advance

Patrick Mitran
nverever AT ee DOT mcgill DOT ca




- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019