
April 13th, 2003, 05:08 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
For printing in uppercase, flip the order of the two statements in the loop, (i.e.) uppercasing the pointer and then increment it. You're incrementing the pointer first and then uppercasing, which is why you're missing the first char:
Code:
while(*text_ptr)
{
putchar(toupper(*text_ptr));
text_ptr++;
}
As for the lowercasing part, you forgot to reset your pointer to the beginning of the string again. As before, also change the order of your statements inside the loop and you should be good to go.
Code:
printf("\n\nThe line of text in lowercase is:\n\n");
text_ptr = text; /* <--- Point text_ptr to the beginning of the string again */
while(*text_ptr)
{
putchar(tolower(*text_ptr));
text_ptr++;
}
I realize that you're probably a beginner to C programming, so I'll give you a little friendly advice. Using gets() is highly discouraged for any serious programming. Consider using fgets() or fread() instead. See the BUGS section in http://www.openbsd.org/cgi-bin/man....386&format=html for why.
Last edited by Scorpions4ever : April 13th, 2003 at 05:11 PM.
|