4

int findNumber(char *exp,int i,int *num)    
{    
    int k=i;    
    char *p;    
    p=exp[i]; //<-- here
    while(*p>='0'&&*p<='9')    
    {
        (*num)=(*num)*10+(*p);
        k++;
        p++;
    }
    return k;
}

i keep getting that error in line: (p=exp[i];) Im trying to send a char array, and (i,num) integers, the 'i' im just putting it to be 0 for now, until the code works so dont give attention to it. but the function should return the place of the first character in "exp" that is not a number, with being sure that all the ones before are numbers.

3 Answers 3

5

p is a char* so you need to assign a pointer to it but exp[i] returns a single char element from an array. Try

p = &exp[i];

or

p = (exp + i);

instead.

Sign up to request clarification or add additional context in comments.

Comments

0

do correct the line to correspond to the following p=&(exp[i]); this means that you are assigning the pointer of exp[i] to p.

Comments

0

You need take the address-of instead of and then pass to p, that's a pointer. In other words,you are assign char to a char* returned from value atiindex inexp` array.

Try this: p = &exp[i];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.