0

While loop memory error in C

My code goes something like this: char* function(char* string){ char* check=string; int found=0; while(*check!='\0'){ if(*check>='0' && *check<='9'){ found=1; break; } check++; } if(found==0) return NULL; } . . . And I get memory error (Process exited with code 139) in line where the while loop is. Why is this happening?

4th Jan 2020, 9:35 PM
ja008
ja008 - avatar
1 Answer
0
Additionallly, looking at the code, it seems you were checking whether the argument given contains any digit. In which case I would probably prefer to return an `int` to signal the caller whether there is any digit in the given argument.
5th Jan 2020, 3:40 AM
Ipang