using an apostrophe in comments will generate the error "unterminated string constant". discovered this while compiling the following source using "gcc myecho.c -o myecho.exe"
error is on line 15:
* and thus be unaware of any whitespace. each approach has it's *
yes... i know that it should be "its" and not "it's" ;-)
/************************************************************************/
* *
* myecho.c (dos version) *
* *
* homemade implementation of the echo command, common to unix & dos, *
* myecho is one half of an experiment that attempts to discern the *
* only apparently visible difference in behavior between the unix *
* dos versions of echo, that being the parsing of whitespace given *
* as input. the included version of echo in unix will strip out all *
* extraneous whitespace and then feed back arguments with one space *
* between each character string. the included version of echo in dos *
* will feed back arguments along with any extra whitespace. my theory *
* is that the dos echo is receiving a single string as an argument, *
* where the unix echo will receive an array of strings as arguments *
* and thus be unaware of any whitespace. each approach has it's *
* advantages and disadvantages, but that is not the concern of this *
* experiment. if myecho will not return whitespace, then we can *
* assume with a reaonable certainty that the dos shell is passing *
* commmand line arguments in a structure similar to that of unix. if *
* the dos shell is instead passing a single string or possibly an *
* array with only two strings, the command and then argument string. *
* we shall see... *
* *
************************************************************************/
#include <stdio.h> /* standard input/output library */
int argc; /* argument count */
char *argv[]; /* array of pointers to strings */
int main(argc, argv) /* unix-style parameters */
{
int i; /* index counter for printf loop */
for(i=1;i<argc;i++) /* loop runs through string array */
{
printf("%s ",argv[i]); /* print each string and a space */
}
printf("\n"); /* print newline */
return(0); /* return no error */
}