When I run that code with Dynamic C 10.72A, I see "13". What happens when you run it? Did you run your tests with some other code or with an older version of Dynamic C?
Here's a version that doesn't modify the source string:
Code:
#include <stdio.h>
#include <string.h>
const char *parse_valco(const char *src)
{
src = strchr(src, '='); // find the equal sign
if (src != NULL) {
++src; // point past the equals sign
while (*src == ' ') {
++src; // skip over any spaces
}
}
return src;
}
int main ()
{
char actualpos[] = "2 Position is = 13";
const char *valco2pos;
valco2pos = parse_valco(actualpos);
if (valco2pos == NULL) {
printf("couldn't find equal sign\n");
} else {
printf("%s\n", valco2pos);
}
}