Answer the question
In order to leave comments, you need to log in
Why is the identifier not defined?
Wrote a function in C? which looks for numbers in a string and then, when it hits a letter, looks for the largest letter of the resulting number, invalidates the variable that held the number, and looks for a new one in the same string. But when I run it, I get the error "w: undeclared identifier". I can't figure out what the problem is.
Function:
int funcc(char a[]) {
int length = strlen(a);
printf("length = %d\n", length);
char num[255];
for (int i = 0; i < length; i++)
{
if (a[i] == '0') {
num[i] = a[i];
}
if (a[i] == '1') {
num[i] = a[i];
}
if (a[i] == '2') {
num[i] = a[i];
}
if (a[i] == '3') {
num[i] = a[i];
}
if (a[i] == '4') {
num[i] = a[i];
}
if (a[i] == '5') {
num[i] = a[i];
}
if (a[i] == '6') {
num[i] = a[i];
}
if (a[i] == '7') {
num[i] = a[i];
}
if (a[i] == '8') {
num[i] = a[i];
}
if (a[i] == '9') {
num[i] = a[i];
}
else {
if (w != 0) {
int a = 0;
while (w > 0) {
int b = w / 10;
if (b > a) {
a = b;
}
w /= 10;
}
}
continue;
}
int w = atoi(num);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question