[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Quick C problem



On Mon, 31 May 1999, Antti-Juhani Kaijanaho wrote:

> This is not a quick question, as you don't tell us all we need to know.

I did actually.

> Is it quaranteed that String1 starts with "<" and ends with ">"?

yes

> Is whitespace allowed at the start and the end of the string?

no

> Must we check for illegal input?

no

> 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;

Thanks... But I got a previous reply in one line.

strcpy(newStr,strtok(tmpString,"<>"));

(From memory)

                     Michael Beattie (mike@omnic.dhis.org)

               PGP Key available, reply with "pgpkey" as subject.
 -----------------------------------------------------------------------------
            Computers are not intelligent. They just think they are.
 -----------------------------------------------------------------------------
                Debian GNU/Linux....  Ooohh You are missing out!



Reply to: