Question: The answer is 7 4 3 . However, I do not understand why n = 3 at the end. #include #include int main ( int

The answer is 743. However, I do not understand why n =3 at the end.
#include
#include
int main (int argc, char *argv[]){
char* str = argv[1];
char* str2= argv[2];
const char ch ='7';
char *p;
p = strchr(str, ch);
printf("%c", p[1]);
p = strrchr(str, ch);
printf("%c", p[1]);
int n = strspn(str, str2);
n += strcspn(str, str2);
n += strnlen(str,2);
printf("%i", n);
return 0;
}
Given the code above, what's the output if we run the program prog with the command "./prog 47747"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!