News for hackers. Stuff that matters.
Re:Helping my students overcome command-line bullshittery (2... by tptacek on Tuesday November 03, 2015 @10:55AM (#10500356)
I 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;
Re:Helping my students overcome command-line bullshittery (2... by marvy on Tuesday November 03, 2015 @02:45PM (#10502020)
Sure 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.

Re:Helping my students overcome command-line bullshittery (2... by tptacek on Tuesday November 03, 2015 @04:00PM (#10502607)
You just chopped the last non-NUL character off that string whether it was a newline or not.
Re:Helping my students overcome command-line bullshittery (2... by marvy on Tuesday November 10, 2015 @10:26PM (#10544658)
ok, you got me there