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

Pages: 1-

strnlen

Name: Anonymous 2009-10-01 11:40

          strnlen ("foobar", 0) = 0
          strnlen ("foobar", 1) = 3
          strnlen ("foobar", 2) = 2
          strnlen ("foobar", 3) = 1
          strnlen ("foobar", 4) = 0
          strnlen ("foobar", 5) = 6
          strnlen ("foobar", 6) = 6
          strnlen ("foobar", 7) = 6
          strnlen ("foobar", 8) = 6
          strnlen ("foobar", 9) = 6

Name: Anonymous 2009-10-01 11:42

VALID STUPID CODE

Name: Anonymous 2009-10-01 11:45

what exactly is the point of this?

Name: Anonymous 2009-10-01 12:07

>>3
It is code to be executed by a computer using a programming language

Name: TRUE TRUTH EXPERT !tQq1sLlmuk 2009-10-01 12:17

>>1

#include <stdio.h>
#include <string.h>

int main(int argc, char **argv) {
  size_t i = 3;
  printf("%zu\n", (size_t[]){(size_t[]){strlen(argv[1])}[0]>i?i:(size_t[]){strlen(argv[1])}[0]}[0]);
  return 0;
}

Name: Anonymous 2009-10-01 14:13

>>5
what, why

Name: Anonymous 2009-10-01 17:15

Pronounced 'stern-len'.

Name: Anonymous 2009-10-01 17:20

>>1
int strnlen(char *str,int n){
    if(strcmp(str,"foobar")==0){
        return n == 0 ? 0 :
               n == 1 ? 3 :
               n == 2 ? 2 :
               n == 3 ? 1 :
               n == 4 ? 0 : 6;
    }else{
        printf("undefined behavior.");
    }
}

Name: Anonymous 2009-10-01 20:02

>>7
Actually, it's "strenalen"

Name: Anonymous 2009-10-01 23:50

>>7 - 9
it's pronounced "ES TEE AR EL EE EN"

Name: Anonymous 2009-10-02 0:35

Stern leen

Name: Anonymous 2009-10-02 4:19

strunlen

Name: Anonymous 2009-10-02 4:26

ES TEE ARE LEN

Name: TRUE TRUTH EXPERT !tQq1sLlmuk 2009-10-02 4:26

>>6
iT'S A SINGLE EXPRESSION DOING WHAT >>1 DOES. c99 BOYO!

Name: Anonymous 2009-10-02 5:25

I wrote a strnlen function once. It's purpose was to find out lengths for strings that may or may not have had a terminating zero.

Name: Anonymous 2009-10-02 5:40

>>15
how would you know where to stop if it was not null terminated?

Name: Anonymous 2009-10-02 6:08

>>15,16

memchr(str, 0, n)

Name: Anonymous 2009-10-02 6:54

>>16
If it didn't find any zero before n characters had been looked through it would return n. Mostly used with n being the size of the buffer, effectively giving you the length of a zero-terminated string or the length of the buffer. Preventing overflow.
It was a symptom of not fuqin sending the length of the data and rely on a terminating character instead. Which could be cut off.

Name: Anonymous 2009-10-02 7:19

Name: Anonymous 2009-10-02 8:15

Name: Anonymous 2009-10-02 11:53

stir en len

Name: Anonymous 2009-10-02 11:58

>>8
No return value ;_;

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