Re: Quick C problem
On Tue, Jun 01, 1999 at 12:33:41AM +1200, Michael Beattie wrote:
> String1: "<firstname.lastname@example.org>"
> want String2: "email@example.com"
This is not a quick question, as you don't tell us all we need to know.
Is it quaranteed that String1 starts with "<" and ends with ">"?
Is whitespace allowed at the start and the end of the string? Must
we check for illegal input?
Anyway, assuming that he answers to the questions above are yes, no, no
respectively, then I'd suggest something like the following, which
destroys the original content of String1 (you can get around that
by using strdup):
String2 = String1 + 1;
String2[strlen(String2)-1] = 0;
%%% Antti-Juhani Kaijanaho % firstname.lastname@example.org % http://www.iki.fi/gaia/ %%%
"... memory leaks are quite acceptable in many applications ..."
(Bjarne Stroustrup, The Design and Evolution of C++, page 220)