I am still a neophyte in the world of programming and am working on writing a program that accepts a string from the user and then returns that string in three different methods:
1) all uppercase
2) all lowercase
3) first letter of each word in uppercase
This "assignment", if you will, was suggested to me by members of the site on the forum. It's helping me to learn to write functions. Also, I am not allowed to use string.h.
I was perusing the site for technical information about converting an entire string to uppercase or lowercase and found this:
My question is, won't this skip every other letter in the string? Should the incremental p used inside the body of the for loop be discarded as it will be incremented on the for line anyway?Code:#include <stdio.h> #include <ctype.h> int main ( void ) { char hello[] = "Hello World"; char *p; printf("Before conversion: %s\n", hello); for ( p = hello; *p != '\0'; ++p) { *p = tolower (*p); ++p; } printf("After conversion: %s\n", hello); return 0; }