PDA

View Full Version : Array sizes do not match


Jack_Leslie
20/12/2011, 11:42 AM
stock CountrySearch(const string[])
{
if (!string[0])
return string;

static
x = sizeof (cntNames),
results_found = 0,
result_string[512],
return_string[512 + 128];

while (x >= 0)
{
if (strfind(cntNames[x], string, false) != -1)
{
results_found += 1;
strcat(result_string, cntNames[x]);
if (results_found > 1) strcat(result_string, "\n");
}
x -= 1;
}

if (results_found >= 0)
{
if (!results_found)
format(return_string, sizeof (return_string), "No results found for '%s'.\nPlease check your spelling and try again.", string);

if (results_found == 1)
format(return_string, sizeof (return_string), "Did you mean: %s", result_string);

else if (results_found <= 10)
format(return_string, sizeof (return_string), "Did you mean one of these?\n%s", result_string);

else
format(return_string, sizeof (return_string), "Did you mean one of these?\n%s\nNOTE: Only the first 10 results are shown, the rest is cut off.", result_string);

return return_string;
}
}


On line:
return return_string;

FarSe.
20/12/2011, 12:21 PM
stock CountrySearch(const string[])
{
static
x = sizeof (cntNames),
results_found = 0,
result_string[512],
return_string[512 + 128];
if (string[0] != EOS)
{
while (x >= 0)
{
if (strfind(cntNames[x], string, false) != -1)
{
results_found += 1;
strcat(result_string, cntNames[x]);
if (results_found > 1) strcat(result_string, "\n");
}
x -= 1;
}

if (results_found >= 0)
{
if (!results_found)
format(return_string, sizeof (return_string), "No results found for '%s'.\nPlease check your spelling and try again.", string);

if (results_found == 1)
format(return_string, sizeof (return_string), "Did you mean: %s", result_string);

else if (results_found <= 10)
format(return_string, sizeof (return_string), "Did you mean one of these?\n%s", result_string);

else
format(return_string, sizeof (return_string), "Did you mean one of these?\n%s\nNOTE: Only the first 10 results are shown, the rest is cut off.", result_string);

}
}
return return_string;
}