[elektro] C kérdés
Ferenc Toth
toferi2 at freemail.hu
Mon Sep 6 10:13:53 CEST 2010
na végül igy csináltam meg
while(!(CAN1Read(&msg_id, Rxdata, &data_len, &rx_flags))){
}
if
((Rxdata[0]==0x10)&(Rxdata[1]==0x70)&(Rxdata[2]==0x7B)&(Rxdata[3]==0x00)&(Rxdata[4]==0x17)&(Rxdata[5]==0x00)&(Rxdata[6]==0xB9)&(Rxdata[7]==0x00))
LED1=0;
nem tul szép ,de muködik.
Megkerestem ezt a memcmp-t és tényleg igazad van .Ez lett volna az igazi...
memcmp
Description: Compare the contents of two buffers.
Include: <string.h>
Prototype: int memcmp(const void *s1, const void *s2, size_t n);
Arguments: s1 first buffer
s2 second buffer
n number of characters to compare
Return Value: Returns a positive number if s1 is greater than s2, zero if s1
is equal to
s2, or a negative number if s1 is less than s2.
Remarks: This function compares the first n characters in s1 to the first n
characters
in s2 and returns a value indicating whether the buffers are less
than, equal to or greater than each other.
Example: #include <string.h> /* memcmp */
#include <stdio.h> /* for printf */
int main(void)
{
char buf1[50] = "Where is the time?";
char buf2[50] = "Where did they go?";
char buf3[50] = "Why?";
int res;
printf("buf1 : %s\n", buf1);
printf("buf2 : %s\n", buf2);
printf("buf3 : %s\n\n", buf3);
res = memcmp(buf1, buf2, 6);
if (res < 0)
printf("buf1 comes before buf2\n");
else if (res == 0)
printf("6 characters of buf1 and buf2 "
"are equal\n");
else
printf("buf2 comes before buf1\n");
----- Original Message -----
From: "Lajos Rancz" <lajos.rancz at gmail.com>
To: <elektro at tesla.hu>
Sent: Sunday, September 05, 2010 12:58 PM
Subject: Re: [elektro] C kérdés
memcmp? Az tuti ki van optimalizalva.
udv,
Lajos
2010. szeptember 4. 9:40 Ferenc Toth írta, <toferi2 at freemail.hu>:
> Sziasztok.
>
> A kérdésem az lenne,hogy a C ben egy tömb elemeit egyszerre meg lehet
> vizsgálni?
> hogy mire gondolok
>
> char DataI[8];
> main{
>
> //ha a DataI =12345678 akkor ....
>
> }
>
> -----------------------------------------
> elektro[-flame|-etc]
-----------------------------------------
elektro[-flame|-etc]
__________ Information from ESET Smart Security, version of virus signature
database 5423 (20100904) __________
The message was checked by ESET Smart Security.
http://www.eset.com
More information about the Elektro
mailing list