Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Herp derp

Name: Anonymous 2011-04-20 12:30

ITT: How you decide the amount of elements in an array in C++ with only a pointer to the array. I bet you can't do it.

Name: Anonymous 2011-04-21 12:09

How do you think strlen works?
Here it is, in FV-style indentation:
[m]int my_strlen(char *s){char *p; for(p=s; *p; p++); return p-s;}/m]
Doing it for any other types would be as trivial.
If you're using a linked list, something like:
for(size=0;*p;p = p->next,size++); would do the job of calculating the total size/length.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List