-
strlen in expressions
hi i am trying to make a program do this basically...
int * strlen / strlen * strlen * strlen = an int
i cannot figure out how to write that in code...
i don't know if you cannot use strlen in a "formula" ? or what?
thanks
mathatmatically
(5000 * 8) / (5 * 8 * 8)
obviously using varibles in the program
thanks again
-
Two methods:
Code:
int main( void )
{
// USING *STRINGS
char *C_Str1;
char *C_Str2;
char *C_Str3;
char *C_Str4;
// Intitalise the *strings
std::cout<< (5000*strlen(C_Str1))/(strlen(C_Str2)*strlen(C_Str3)*strlen(C_Str4));
// USING STD::STRING
std::string one;
std::string two;
std::string three;
std::string four;
// Initalise the std::strings
std::cout<< (5000 * one.size()) / (two.size() * three.size() * four.size());
return 0;
}
Or something to that effect.
-
Try: x = (a*b)/(c*d*e);
= is for assignment, you can't assign a value to a mathematical calculation, that's why x that gets the value is on the left.
Also use brackets to make the statement non-ambigous.
-
justforthis1, in the future could you make your titles a little more informative, for example "strlen in a formula" rather than "dumb newb question".
-
ok thanks, that helps a lot, it works now anyways
sorry about the title, i will do better next time
thanks