Answered! Write code to define a function as follows: 1. function is named foo 2. foo takes a pointer to a character and returns…

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. C PROGRAM with prinf and scanf

Expert Answer

#include<stdio.h>
#include<string.h>
char check1(char chck);
int foo(char *p){

Don't use plagiarized sources. Get Your Custom Essay on
Answered! Write code to define a function as follows: 1. function is named foo 2. foo takes a pointer to a character and returns…
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
Order Essay

int x=0, count = 1, i;
char c;
if(*p == ‘’)
return x;
else
{
for(;*p;p++)
c = check1(*p);
}
return c;
}
char check1(char chck){

char f[3];
static int i;
if(chck != ‘’)
f[i++] = chck;
if(strcmp(f, “foo”)==0)
return 1;
else
return 0;
}
int main(){

int ret;
char str[10];
printf(“enter string: “);
scanf(“%s”, str);
ret = foo(str);
printf(“%dn”, ret);
}

Answered! Write code to define a function as follows: 1. function is named foo 2. foo takes a pointer to a character and returns... 1

Still stressed from student homework?
Get quality assistance from academic writers!