strlen type

Goi

Diamond Member
Oct 10, 1999
6,772
7
91
Hi,
Can anyone tell me how to typecast strlen's size_t return type to int? I'm trying to use it to access an character array (basically a string) by doing like filename[strlent(filename) - 2] but cc keeps giving me a warning about size_t and int conversion.

Thanks!
 

Goi

Diamond Member
Oct 10, 1999
6,772
7
91
I tried that, but it didn't work. I still get the following cc error:
cc: Info: csg.c, line 4201: In this statement, the return type for intrinsic "strlen" is being changed from "size_t" to "int". (intrinsicint)
filename[(int)strlen(filename) - 2] = NULL;
 

Goi

Diamond Member
Oct 10, 1999
6,772
7
91
Thanks, that did the trick. I thought I had to include it, but then the program worked without it, other than the warning.