Fw: [PHP] Size of a string

From: Date: Wed, 05 Jul 2000 17:37:53 +0000
Subject: Fw: [PHP] Size of a string
Groups: php.general 
Request: Send a blank email to php-general+get-5015@lists.php.net to get a copy of this message
Wrong ... main() { char foo[256]; strcpy (foo,"Hello, World"); printf ("sizeof=%d, strlen=%d\n", sizeof(foo), strlen(foo)); } Do : sizeof=256, strlen=12 sizeof return the static length, in bytes of a variable or structure (mostly aligned on word boudary, depending of the compiler) strlen return the size of a zero terminated string. +-----------------------------+----------------------+ | Olivier BUSSIER | TEL : +33 3 90677065 | | Software department manager | GSM : +33 6 07682507 | | ATLinks | FAX : +33 3 90677080 | +-----------------------------+----------------------+ > ----- Original Message ----- > From: "Corey Mosher" <corey@hub.org> > To: <php-general@lists.php.net> > Sent: Wednesday, July 05, 2000 2:53 PM > Subject: Re: [PHP] Size of a string > > > > No, I mean the size in bytes, not the length. Sizeof in c determines > > the size in bytes, strlen determines the length. > > > > Corey > > > > On Wed, 5 Jul 2000, Daniel Gustafsson wrote: > > > > > At 08:33 AM 7/5/00 -0400, you wrote: > > > >Hello, > > > > Does anyone know how to get the size in bytes of a string? > > > >Is there a function similar to the c function sizeof? > > > > > > You mean the length of the string?.. strlen(), that's what you use in C > too =) > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > > For additional commands, e-mail: php-general-help@lists.php.net > > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > > Corey Mosher > > Hub.Org Networking Services > > Wolfville, NS > > Canada > > corey@hub.org > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > >

« previous php.general (#5015) next »