Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

this is c programming Write code to define a function as follows: 1. function is

ID: 3845750 • Letter: T

Question

this is c programming

Write code to define a function as follows: 1. function is named foo 2. foo takes a pointer to a character and returns an integer named x. 3. foo uses the pointer to check what it's pointing to, if it is a character terminator, the functions returns an integer named x. 4. If not, foo counts by 1 if a call to an assumed function named, check1 returns 1. check1 requires one character argument and returns 0 or 1. You do not need to write the definition of check1; assume it's already defined. 5. make sure to advance the pointer to the next character unless the terminator is found.

Explanation / Answer

It seems more details are required. nothing much has been told for x. Currently x is being assigned to count

The function is as follows:

int foo(char *p){

    int count;
    int x;
    count = 0;   
    while (*p != ''){
         if (check(*p) == 1){
             count++;
         }
         p++;
    }
    x = count;
    if (*p == '')
       return x;
}