There are other (hidden) requirements (otherwise, you cannot pass the test):
1 If the first letter is capitalized, it does not change. 2. Not the same as the English alphabet
e.g.
Input:hello world! This is _LJJ speaking! Output:hello world! This is _LJJ speaking!
The idea is written in the comments.
/*Input A String * output:uppercase the first character of Evrey word * if already uppercased, or other ASC Ii-ch, no change on them * * the thinking:using ASCII * e.g. ' a ' +32 = ' a ' * **/#include<stdio.h>#include<string.h>#defineMax_num 128intMain () {Chars[max_num]={0}; Fgets (S, max_num, stdin); intLen = (int) strlen (s); if(s[0]>='a'&& s[0]<='Z') s[0] -= +; for(intI=0; i<len; i++){ if(S[i] = =' '){ if(s[i+1]>='a'&& s[i+1]<='Z') S[i+1] -= +; }} printf ("%s\n", s); return 0;}
For C, there are a few things to note about the input of strings:
1. If you want to read a string into the program, you must first reserve the space to store the string (typically a string array is first created, and it is already allocated in size.) such as Char str[80];), and then make
Use the input function to get the string;
2. The input function needs to know when the input is finished, get(char *) know the end of the line break , add the empty character '\ s ' At the end, and then pass it on to the program (so Mughal ' n ' reserve space);
3. fgets (< #char *restrict#>, < #int #>, < #FILE *#>) has three parameters, the first one is to store the input string, and the second is the length limit , you need to fill in the maximum allowable input characters
Number, if n is filled, up to read n-1 characters, or to line break stop. The third parameter describes which file to read, and when reading data from the keyboard , fill in stdin(defined in stdio.h);
4. Get () does not check whether the reserved storage can accommodate the actual input data, the extra word inode overflow into the adjacent memory area, so it is not secure. The book gives an example of some of the previous operating system code used
Get (), so a hacker took advantage of this weakness, with a long input to cover the operating system code, this is the "worm" virus. and fgets () limits the length, so a safer way is to use
Fgets () instead of gets ();
5. scanf (< #const char *restrict, ...#>) stops with whitespace characters (such as spaces, tabs, newline characters), so it's more useful for getting word (get word) Rather than getting
character string (get string) ;
Reference: "C Primer Plus 5th Edition"
PS: Blog Park Web-side support for Safari doesn't seem so good.