What if NULL is passed in strchr()

4.1k views Asked by At

I have my code running in Linux. I see my program getting aborted when a NULL is passed to strchr() function. This doesn't seem to happen when running in AIX.

Can anyone tell why this difference in behavior for strchr() ?

Thanks

1

There are 1 answers

2
Scott Hunter On

Because the spec for strchr() doesn't specify the "correct" behavior when passed a NULL, so different implementations are free to, uh, implement it differently for that case. (Just curious: what does the AIX version return when passed a NULL?)