התוכנה כותבת לי שגיאה על המילה
strndup
אולי מישהו יודע אם זה משתנה בגרסאות של וויזואל סטודיו ואיך אפשר לסדר זאת?

char tav = str[strlen(str)/2+1];
int a,b,anser;
char* as = strndup(str, strlen(str) / 2 - *str);
char* bs = strndup(str+ strlen(str) / 2 - *str+2, strlen(str) / 2 - *str);
a = atoi(as);
b = atoi(bs);
if (tav == '+')
    anser = a + b;
else if (tav == '-')
    anser == a - b;
else if (tav == '*')
    anser == a * b;
else if (tav == '/')
    anser == a / b;

puts(str);

Recommended Answers

All 2 Replies

It should be anser = instead of double equals the way you did for the plus sign, for the other operations, when making assignments.

commented: If the error was just on strndup(), could this incomplete code be missing the include statements too? +15
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.