f



"some\0\0\0\0\0\0"

can i use such form of adding zeros to the strings/literals to 'pad' them with zeros ?
or this is not guwranteed to work? need that for 
assuring that strings for example arepadded to
some amount of bytes thus using fast compare which only checks some amount of data and do not bother for checking ends, etc 9you know what i mean)
0
fir
8/13/2015 7:30:19 PM
comp.lang.c 30657 articles. 5 followers. spinoza1111 (3246) is leader. Post Follow

5 Replies
1021 Views

Similar Articles

[PageSpeed] 49

On Thu, 13 Aug 2015 12:30:19 -0700, fir saw fit to publish the following:

> can i use such form of adding zeros to the strings/literals to 'pad'
> them with zeros ?

Yes you can. (I feel SOOO presidential right now)

> or this is not guwranteed to work?

As long as the char-array is big enough, it works.

 need that for assuring that strings
> for example arepadded to some amount of bytes thus using fast compare
> which only checks some amount of data and do not bother for checking
> ends, etc 9you know what i mean)

It should not really make a difference. If it does, you're probably doing 
something wrong.

0
Kleuske
8/13/2015 7:54:53 PM
> can i use such form of adding zeros to the strings/literals to 'pad' them with zeros ?

String literals are supposed to contain the characters you put in
them (plus the trailing \0), and that includes \0's at the end (or
in the middle or at the start).  The literal in the subject: line
should be of length 11, including 7 trailing \0's.

> or this is not guwranteed to work? need that for 

> assuring that strings for example arepadded to
> some amount of bytes thus using fast compare which only checks some amount of data and do not bother for checking ends, etc 9you know what i mean)

I'm really not sure how you are going to gain any speed with this.
If you're counting on doing word-at-a-time (or bigger chunks)
comparisons, remember that string literals aren't guaranteed to be
aligned, and depending on your code, the string you are comparing
against may not be either.


0
gordonb
8/13/2015 8:17:18 PM
W dniu czwartek, 13 sierpnia 2015 22:17:29 UTC+2 u=C5=BCytkownik Gordon Bur=
ditt napisa=C5=82:
> > can i use such form of adding zeros to the strings/literals to 'pad' th=
em with zeros ?
>=20
> String literals are supposed to contain the characters you put in
> them (plus the trailing \0), and that includes \0's at the end (or
> in the middle or at the start).  The literal in the subject: line
> should be of length 11, including 7 trailing \0's.
>=20
alright okay then, though i assume strlen would give only "4" here


> > or this is not guwranteed to work? need that for=20
>=20
> > assuring that strings for example arepadded to
> > some amount of bytes thus using fast compare which only checks some amo=
unt of data and do not bother for checking ends, etc 9you know what i mean)
>=20
> I'm really not sure how you are going to gain any speed with this.
> If you're counting on doing word-at-a-time (or bigger chunks)
> comparisons, remember that string literals aren't guaranteed to be
> aligned, and depending on your code, the string you are comparing
> against may not be either.

if i pad some literals up to some minimal value, (like all them padded up t=
o 16 butes and none larger) i can do some fastest compares - but dont matte=
r

as to alignment i dont know, probably in gcc they will be aligned to 4 anyw=
ay (or no?)
even if mislaligned sse compare should work
too (or no?) same as by-int compares..
0
fir
8/13/2015 8:40:17 PM
On Thu, 13 Aug 2015 12:30:19 -0700 (PDT)
fir <profesor.fir@gmail.com> wrote:

> can i use such form of adding zeros to the strings/literals to 'pad'
> them with zeros ? or this is not guwranteed to work? need that for 
> assuring that strings for example arepadded to
> some amount of bytes thus using fast compare which only checks some
> amount of data and do not bother for checking ends, etc 9you know
> what i mean)

Just write your own string structure eg pointer and length. It would be
far faster to check lengths first then compare if equal...
Having you string structure & interface functions has advantage that
you can perform any optimizations you like. 
0
Melzzzzz
8/13/2015 8:53:12 PM
On 13/08/15 22:40, fir wrote:
> W dniu czwartek, 13 sierpnia 2015 22:17:29 UTC+2 użytkownik Gordon
> Burditt napisał:
>>> can i use such form of adding zeros to the strings/literals to
>>> 'pad' them with zeros ?
>> 
>> String literals are supposed to contain the characters you put in 
>> them (plus the trailing \0), and that includes \0's at the end (or 
>> in the middle or at the start).  The literal in the subject: line 
>> should be of length 11, including 7 trailing \0's.
>> 
> alright okay then, though i assume strlen would give only "4" here
> 
> 
>>> or this is not guwranteed to work? need that for
>> 
>>> assuring that strings for example arepadded to some amount of
>>> bytes thus using fast compare which only checks some amount of
>>> data and do not bother for checking ends, etc 9you know what i
>>> mean)
>> 
>> I'm really not sure how you are going to gain any speed with this. 
>> If you're counting on doing word-at-a-time (or bigger chunks) 
>> comparisons, remember that string literals aren't guaranteed to be 
>> aligned, and depending on your code, the string you are comparing 
>> against may not be either.
> 
> if i pad some literals up to some minimal value, (like all them
> padded up to 16 butes and none larger) i can do some fastest compares
> - but dont matter
> 
> as to alignment i dont know, probably in gcc they will be aligned to
> 4 anyway (or no?) even if mislaligned sse compare should work too (or
> no?) same as by-int compares..
> 

No, string literals will not necessarily be aligned - and you don't have
control of their alignment.  (You can force alignment of variables and
consts, by using __attribute__((aligned)), or C11 _Alignas, but AFAIK
you can't change alignment of string literals in gcc.)

But on x86, misaligned accesses are legal even though they are slower
than aligned accesses.
0
David
8/14/2015 6:37:08 AM
Reply:

Similar Artilces:

#if 0?0?0:0:0
The following 4-lines source fragment test.c (fourth line empty) #if 0?0?0:0:0 #endif int main(void){return 0?0?0:0:0;} cause: test.c(1) : fatal error C1017: invalid integer constant expression when compiled by cl.exe aka "Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86". On the other hand this compile and runs fine. #if 0?(0?0:0):0 #endif int main(void){return 0?0?0:0:0;} Did I hit a but it this compiler's preprocessor? Francois Grieu On 3/30/2010 12:47 PM, Francois Grieu wrote: > The following 4-lines source fr...

(= 0/0 0/0)
Hi, shouldn't > (= 0/0 0/0) => NIL or > (= 0/0 0/0) => T instead of giving out division by zero? 0/0 is different from 1/0, which is the non-existent number n such that 1 x n = 0. The actual result of that expression depends of what you think 0/0 is. I personally feel that 0/0 is any number n such that 0 x n = 0, that is all numbers. hal9@cyberspace.org (Hal Niner) writes: > Hi, > > shouldn't > > > (= 0/0 0/0) => NIL > > or > > > (= 0/0 0/0) => T > > instead of giving out division by zero? 0/0 is different fro...

0,0 not 0,0
hi all, i have 2 drawings - ground floor and first floor. when i do an ID on a point on the grid i get the same readings for both drawings however, when i xref one into the other or both into a new drawing they come in in different locations. i've checked they're both using world UCS and the same units. any ideas? i thought with autocad 0,0 was always 0,0? cheers rob "Coro, Rob" <RE-Coro@bdp.co.uk> schrieb: >hi all, > >i have 2 drawings - ground floor and first floor. when i do an ID on a >point on the grid i get the same readings for bo...

IP 0.0.0.0/0
Hi Any useful link that explains this IP address range in details, please? Thanks in advance! The Dude In article <Jp6Hg.458762$IK3.24918@pd7tw1no>, The Dude <The Dude@thedu.de> wrote: >Any useful link that explains this IP address range in details, please? Urrr -- 0.0.0.0/0 is the *entire* IPv4 address range, and 0.0.0.0/32 is just the single IPv4 address 0.0.0.0. For any given network, the lowest address in the network is reserved. Historically, the lowest address was one of the two allowed choices for the broadcast address; later, the broadcast a...

Changing ". . . # . # ." into " 0 0 0 1 0 1 0"
Is there an easy way to change ". . . # . # ." into " 0 0 0 1 0 1 0"? i.e. changing an array of dots and hashes that another programme I'm using outputs, into 0s and 1s that I can then use in Matlab? Many thanks, Tom In article <ef19cb8.-1@webx.raydaftYaTP>, Tom <thomas.cole@lincoln.ox.ac.uk> wrote: > Is there an easy way to change ". . . # . # ." into " 0 0 0 1 0 1 0"? > i.e. changing an array of dots and hashes that another programme I'm > using outputs, into 0s and 1s that I can then use in Matlab? > > Many tha...

0.0**0 = ?
I'm wondering if 0.0**0 (as opposed to 0.0**0.0) has the value 1 as per fortran standard or if this is left to the compiler vendors (different vendors do different things, unhappily). Thanks, Joost Joost VandeVondele wrote: > I'm wondering if 0.0**0 (as opposed to 0.0**0.0) has the value 1 as > per fortran standard or if this is left to the compiler vendors > (different vendors do different things, unhappily). > > Thanks, > > Joost Surely, 0.0**0.0 is mathematically undefined? Therefore, I wouldn't expect the standard to make any pronouncement about the ...

Simplifying {0,0,0}.X.{0,0,0}
Hello, In brief: Is there a way that I can specify that "X" is a matrix and will resolve to zero when dot multiplied with a vector of zeros? I'm constructing a swathe of expressions that contain things like (when expanded): {0,0,0}.X.{0,0,0}, where X is an arbitrary (well, positive definite) square matrix of obvious size, and I'd like to be able to have mathematica simplify that for me without much intervention. My only option at the moment is to manually perform the replacements {{0, 0, 0}.X._ -> 0, _.X.{0, 0, 0} -> 0} (the left and right vectors won...

0:0:0:0:phone
Under kerio Admin screen,local Address I get: 0:0:0:0:phone where "phone" is the local port number. What the hell is that supposed to mean? MikeStevens.invalid@spamtrap.org wrote: > Under kerio Admin screen,local Address I get: 0:0:0:0:phone > > where "phone" is the local port number. What the hell is that supposed to > mean? That's illegal -- there should be nothing coming from 0.0.0.0 at all, on ANY port. Block that IP outright. -- Cinemuck, n.: The combination of popcorn, soda, and melted chocolate which covers the floors of movie thea...

what is the significance of 0.0.0.0
is this the default gateway of whole internet. or is this the default gateway of a whole class A ip addresses. or is this a network address of a particular sub-net. please explain it pragmatically with regards novice wrote: > is this the default gateway of whole internet. > or is this the default gateway of a whole class A ip addresses. > > or is this a network address of a particular sub-net. > please explain it pragmatically > with regards Written that way, it's nothing more than an IP address. On 10/04/2010 02:53 PM, novice wrote: > is this the default gatewa...

*.so , *.la , *.a , *.so.0.0.0 , *.so.1.0.0 ...
I noticed so many extensions in the /usr/lib directory of my Linux system. .so stands for shared object but also there are other extensions can anyone please explain or atleast give pointers to where I can find information about these extensions in details. regards, Onkar onkar <onkar.n.m@gmail.com> wrote: > I noticed so many extensions in the /usr/lib directory of my Linux > system. .so stands for shared object but also there are other > extensions can anyone please explain or atleast give pointers to where > I can find information about these extensions in detail...

How to interpolate a [0 0 0 1 0 0 ...0 1 0 0 0 ...0 0] vector please help
dear friends, i have t vector; t=linspace(0,.00007,76); k vector is [0 0 0 1......1 0 0 ..], its like all zeros except two 1`s, on a different time instants. when i apply this command ; k=interp1(tau,k,t); tau is also the same as t. one question is that,do we need to interpolate the vector k from one time vector to another of the same length? as here length(t)=length(tau). second question is that when i apply this command, the vector k is returned as a single entry???? please help me on this one. thanks "salman " <salmanabdullah9@gmail.com> wrote in message <iujd42$s...

Re: Simplifying {0,0,0}.X.{0,0,0}
Hi Jens, and others, On Mar 7, 6:10 pm, Jens-Peer Kuska <k...@informatik.uni-leipzig.de> wrote: > Hi, > > X /: Dot[X, a : {0 ..}] := a > > will help. Ah! TagSet, I get it; very useful. Mathematica is rather amazing. Its syntax is more flexible than I can imagine, coming from another system & TeX. Thanks all, Will ...

DHCP weirdness
[sorry for the long post...] Hi folks, I'm trying to set up network booting for some x86 clients from an x86 server, both running Solaris 10 03/05. I am seeing long delays in the middle of the boot process which seem to be down to a weird response by the DHCP server to a client DHCP Discover request part way through boot. If any folks with DHCP experience are reading this, I'd really appreciate any advice you might offer. Running the DHCP server in debug mode shows that thing start off OK: [scroll down for interposed commentary] -bash-3.00# /usr/lib/inet/in.dhcpd -d -v 4222c8...

TSP: intercepting "WSPConnect": value of "name" parameter always "0.0.0.0"?
Hello, using the Microsoft TSP-example and intercepting "WSPConnect" (see code snippet below), I found that I would always get "0.0.0.0" and some random port for the local and remote endpoints. Shouldn't the "name" parameter of "WSPConnect" contain the actual remote IP endpoint to which the user application is connecting to? ----8<------------- SOCKADDR_IN localAddr; SOCKADDR_IN *pRemAddr = (SOCKADDR_IN *)name; int sockAddrLen = sizeof(SOCKADDR_IN); getsockname(SocketContext->ProviderSocket, (SOCKADDR *)&localAddr, &soc...

Web resources about - "some\0\0\0\0\0\0" - comp.lang.c

Resources last updated: 1/25/2016 8:39:12 AM