Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!ucsd!orion.oac.uci.edu!ucivax!ucla-cs!rutgers!rochester!pt.cs.cmu.edu!o.gp.cs.cmu.edu!andrew.cmu.edu!ghoti+ From: ghoti+@andrew.cmu.edu (Adam Stoller) Newsgroups: comp.lang.c Subject: Re: Is there a good example of how toupper() works? Message-ID: Date: 17 Oct 90 12:54:28 GMT References: <2466@ux.acs.umn.edu> <15857@csli.Stanford.EDU> <1990Oct16.221035.10764@nntp-server.caltech.edu> Organization: Information Technology Center, Carnegie Mellon, Pittsburgh, PA Lines: 35 In-Reply-To: <1990Oct16.221035.10764@nntp-server.caltech.edu> Both the original code posted and that as supplied by others - seems to accept the fact that char *duh = "Hello"; can be modified. From what I recall, for your simple test function to work, you would either have to use: char duh[] = "Hello"; or pass/read in a string into either a malloc'ed area or char array -- before being able to modify it. Of course I could be wrong - but...for my $0.02 function contribution: #include int main() { char duh[] = "Hello"; /* see (1), below */ char *s = NULL; printf("%s\n", duh); for (s = duh; *s != '\0'; s++){ *s = toupper(*s); /* see (2), below */ } printf("%s\n", duh); } (1) some older compilers will require this to be declared static, before allowing you to use aggregate initialization. (2) under ANSI you don't need to test for islower() - pre-ANSI requires the islower() test because many of the macros used to define islower and toupper were brain-dead --fish