#include
Int str_fun (char * p);
Int main (int arg c, char * argv [])
{
Char [] s="ho3llewrftridgeefvhtydv";
int n;
N=str_fun (s);
Printf (" n=% d \ n ", n);
return 0;
}
Int str_fun (char * p)
{
Int num=0;
While (* p!='\ 0') {
If (* p<='z' & amp; & * p> {
='a')Num++;
Printf (" % d ", num);
P++;
}}
return num;
}
CodePudding user response:
Change the string to global productionCodePudding user response:
I have this program with a pointer to the string, this does not affect, if I put the string all letters, not Numbers, the program can normal execution,The question now is I already know why my program dead cycle, when the * p=3, the program will not enter the if statement, p++ not executed, thus appeared the infinite loop, this I know, but the first two cycle carried out as normal, the individual feels output will be two times the value of num, but actual of infinite loop directly, without any output,
CodePudding user response:
You met this program is beyond the scope of a to z characters of dead cycle, p++ if judgment outsideCodePudding user response:
If you add a sleep after each printing can be printed