How to use strnlen in windows with C

1 Answer

0 votes
#include <windows.h>
#include <string.h>
#include <stdio.h>

int main(void)
{
    char* str1 = "c windows programming";
    char* str2 = "strnlen takes a maximum size. If the string is longer\n"
                 "than the maximum size, the maximum size is\n"
                 "returned not the actual size of the string";

    size_t len;
    size_t maxsize = 25;

    len = strnlen(str1, maxsize);
    printf("%zu\n", len);

    len = strnlen(str2, maxsize);
    printf("%zu \n", len);

    char ch = getchar();

    return 0;
}
 



/*
run:

21
25

*/

 



answered Apr 6, 2022 by avibootz

Related questions

2 answers 243 views
1 answer 185 views
1 answer 200 views
1 answer 219 views
219 views asked Apr 6, 2022 by avibootz
1 answer 170 views
1 answer 202 views
1 answer 192 views
...