2 ms·
Don't write things like that, people might believe you. That is not at all what it does. http://www.cplusplus.com/reference/cstring/strcspn/ http://www.cplusp
by marvy 11y ago
Don't write things like that, people might believe you. That is not at all what it does.
http://www.cplusplus.com/reference/cstring/strcspn/ http://www.cplusplus.com/reference/cstring/strcspn/
- tptacek 11y agoI don't think he's being entirely serious, but you obviously can use it that way: char foo[] = "this is a test\n"; foo[strcspn(foo, "\n")] = 0;
- marvy 11y agoSure you can do that, but strcspn only found the newline, it didn't delete it. After all, you can also do foo[strlen(foo)-1] = 0; But I don't think anyone would say strlen modifies the string.