Home > Back-end >  Ask a basic question
Ask a basic question

Time:09-23

Ask bosses what was going on, what should change, thank you very much
Code:
#include
Int * find (int * p, int l, int x) {
Int a [100], I;
For (p=a; pIf (* p==x);
return p;
If (* p!=x)
The return p - l - 1;
}
}
Int main () {
Int a [5], * p, I, x, l, s;
Printf (" a: ");
For (p=a; p
The scanf (" % d ", p);
Printf (" x, ");
The scanf (" % d ", & amp; X);
S=find (p, l, x) - p;
Printf (" % d \ n ", s);
return 0;
}

CodePudding user response:

# include & lt; Stdio. H>
Int * find (int * p, int l, int x)
{
Int * TMP;//here you define int a [100] no dice, doesn't have anything to do with a [5] in the main, X can't find in here
For (TMP=p; TMP & lt; P + l; Tmp++)
{
If TMP (*==x)//behind if statements best add parentheses, but surely not add;
return tmp;
}
The return p - 1;
}
Int main ()
{
Int a [5], * p, x, l=5, s;//l for the length of the array, you have nothing to initialize oh
Printf (" a: ");
For (p=a; p
The scanf (" % d ", p);
P=a;//after reading the input, p has pointed to the array of addresses, to make it to the first address array
Printf (" x, ");
The scanf (" % d ", & amp; X);
S=find (p, l, x) - p;
Printf (" % d \ n ", s);
return 0;
}

CodePudding user response:

The
reference 1/f, 5250 response:
# include & lt; Stdio. H>
Int * find (int * p, int l, int x)
{
Int * TMP;//here you define int a [100] no dice, doesn't have anything to do with a [5] in the main, X can't find in here
For (TMP=p; TMP & lt; P + l; Tmp++)
{
If TMP (*==x)//behind if statements best add parentheses, but surely not add;
return tmp;
}
The return p - 1;
}
Int main ()
{
Int a [5], * p, x, l=5, s;//l for the length of the array, you have nothing to initialize oh
Printf (" a: ");
For (p=a; p
The scanf (" % d ", p);
P=a;//after reading the input, p has pointed to the array of addresses, to make it to the first address array
Printf (" x, ");
The scanf (" % d ", & amp; X);
S=find (p, l, x) - p;
Printf (" % d \ n ", s);
return 0;
}

Don't the zha, I how also forget to initialize the , thank you bosses!
  • Related