CodePudding user response:
One by one check, if not Numbers and the decimal point is ignoredCodePudding user response:
Did not form a complete set of code, but I can give you a similar reference code, only on the basis of the need to do some modifications.If you still want to know some of the other common type, can take a look at this article https://blog.csdn.net/HYNN12/article/details/102610626, hope to help you.
#include
Int main (int arg c, const char * argv []) {
Int num_digital=0;
Int num_char=0;
Int num_space=0;
int i;
Char c [100]="faj afhka123 f";
//gets (c);
for (i=0; i<100; I++) {
If (c [I]==' ') {
Num_space + +;
}
If ((c [I] & gt;='A' & amp; & C [I] <='Z') | | (c [I] & gt;='a' & amp; & C [I] <)='z') {
Num_char + +;
}
If (c [I] & gt;='0' & amp; & C [I] <='9') {
Num_digital + +;
}
}
Printf (" digital number is the number is % d % d \ n the letter number is % d \ n \ n space ", num_digital, num_char, num_space);
return 0;
}
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Copyright statement: this article to CSDN blogger (know,,) in the original article, follow the CC BY 4.0 - SA the copyright agreement, reproduced and this statement, please attach the original source link
The original link: https://blog.csdn.net/HYNN12/article/details/102610626
CodePudding user response:
# include & lt; stdio.h>
#include
#include
# define MAX_INPUT_SIZE 128
Char * del_char STR (char *);
Int main (void)
{
Char input [MAX_INPUT_SIZE];
Float num.
The fgets (input, MAX_INPUT_SIZE stdin);
Del_char (input);
Puts (input);
Sscanf (input, "% f", & amp; Num);
Printf (" % f \ n ", num);
return 0;
}
Char * del_char (char * STR)
{
TMP, char * * back_str;
TMP=back_str=STR;
While (* STR) {
If (isdigit (* STR) | | * STR=='. ')
* tmp++=* STR;
Str++;
}
* TMP=0;
Return back_str;
}
For your reference ~
More than one input, one can consider it
CodePudding user response:
Thank you for your , I try, don't reply