> printf("Location: %lu\n", (argv[1], "#"));
What!?
Code:
$ gcc -Wall bar.c
bar.c: In function ‘main’:
bar.c:6:39: warning: left-hand operand of comma expression has no effect [-Wunused-value]
6 | printf("Location: %lu\n", (argv[1], "#"));
| ^
bar.c:6:25: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘char *’ [-Wformat=]
6 | printf("Location: %lu\n", (argv[1], "#"));
| ~~^ ~~~~~~~~~~~~~~
| | |
| | char *
| long unsigned int
| %s
> When you run `program \#here` it lists the location as 1, which is correct. When you run `program there#` it says the position is 0, which is wrong.
Maybe read the manual page again.
The strspn() function calculates the length (in bytes) of the initial segment of s which consists entirely of bytes in accept.
As written, all you're doing is counting how many leading # there are in the string.
The number and placement of # anywhere else in the string is irrelevant.