So I got this code sample which I wrote. My goal was to print those numbers in print which is stored in ptr char variable. Therefore the first part of the code works.
#include & lt; Stdio.h & gt; # Include & lt; Stdlib.h & gt; Zero primary (four * P); Int main (int argc, char * argv []) {char * ptr; Ptr = "John 5, Jim 2 and Maria 12"; Preg (ptr); Return 0; } Zero Element (four * P) {while (* p! = '\ 0') {if (* p & gt; = '0' & p; l & lt; = '9') {Push (* P) ); } * P ++; }}
But if I change the pre-function to:
zero primary (four * p) {while (* p! = ' 0 ') {If (* p & gt; =' 0 '|| * p & lt; =' 9 ') // & lt; --- changed to logical or push (* P); } * P ++; }}
Does the program print the entire sentence? It sounds strange to me because in this case both the logical operators find it suitable for the given task. I hope someone will tell me the difference I suspect that the way the number of characters is compared with the same number, the characters are displayed as an integer.
* p> = '0' || * P & lt; = '9'
is true, because '9' & gt; = '0'
.
Comments
Post a Comment