c - how do remove enclosing brackets from string? -


i have

char s9[7] = "[abcd]"; 

how remove brackets [] that

s9 == "abcd" 

i have tried

s9 = s9.substring(1, s9.length-2); 

throws error in cygwin

a2v2.c:42:13: error: request member ‘substring’ in not structure or union a2v2.c:42:29: error: request member ‘length’ in not structure or union 

edit:

i realised error, beginner @ c , couldnt differentiate between c , c++ code, regards

someone correct me if i'm wrong, since c standard know couple of decades old, far know, c doesn't offer standard support string manipulation, , in fact doesn't officially have concept of strings. (or of object functions, matter.) instead, c uses pointers, more powerful, more dangerous in can mess things if don't learn way around them.

the important thing, if want c programmer learn c. @ least, need "string manipulation c" , read of pages pop up.

there many ways want. think 1 of faster ones (though modifies string you're looking at. if matters, choose way):

// trim off last character s9[strlen(s9) - 1] = '\0'; // char * points s9 array.  +1 makes @  // second element, substring string need char * substring = s9 + 1; 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -