This rather small problem is proving a bit of a nuisance. I have a string that looks like this:
Code:a_long_string_with_lots_of_underscores
I need to trim off the final "_underscores", and so thought that the following plan might work:
The compiler doesn't like the comparison, or the assignment of "\0" to an array element. Would anyone mind telling me why? Thanks.Code:char fname[64]; //a string is generated by another part of the code and //copied into fname with strcpy at this point int len = sizeof(fname) -1; int k; for (k=len;k>0;k--) { if (fname[k] == "_") { fname[k] = "\0"; printf("String shortened to: %s\n",fname); } }