int main ()
int strlen(char*s)
{char *p = s;
while (*p! = '/0');
p++;
return p - s;
What does this program do?
This is a discussion on Problem with String length within the C++ Programming forums, part of the General Programming Boards category; int main () int strlen(char*s) {char *p = s; while (*p! = '/0'); p++; return p - s; What does ...
int main ()
int strlen(char*s)
{char *p = s;
while (*p! = '/0');
p++;
return p - s;
What does this program do?
To understand, take a ruler, choose a mark near the left (point A) and the right (point B). If you subtract A from B, you should get the length of segment AB. That's what the program does.
> What does this program do?
It doesn't do a damn thing, because it won't compile.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.
yes salem is right.