I can't seem to find this anywhere, but does strcspn() return -1 when str1 does not contain str2? For example, say I have:
strcspn(argv[1], " ");
Will the function return -1 or something else if argv[1] does not contain a space?
See strcspn reference on cplusplus.com
strcspn(str1, str2)
returns
The length of the initial part of str1 not containing any of the characters that are part of str2. This is the length of str1 if none of the characters in str2 are found in str1.
So your call strcspn(argv[1], " ");
should return the length of argv[1]
.