לימוד ארדואינו שפת סי – פונקציות ומחרוזות
לימוד ארדואינו : שיעור 12 – מחרזות ופונקציות – קורס c506
דוגמא 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
// www.robotronix.co.il // לימוד שפת סי , בסביבת ארדואינו קורס C506 // רובוטרוניקס מפתחת תוכנה ואלקטרוניקה - משדרים כרטיסים אלקטרונים // קורסים למהנדסים , בתי ספר , ונוער #include <stdio.h> #include <string.h> int a,b,c; char email[80]; void setup() { Serial.begin(9600); strcpy(email,"dev@robotronix.co.il"); CheckEmail(email); // put your setup code here, to run once: } void loop() { // put your main code here, to run repeatedly: delay(2000); } int CheckEmail(char p[]) { Serial.print(p); } |
דוגמא 2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
// www.robotronix.co.il // לימוד שפת סי , בסביבת ארדואינו קורס C506 // רובוטרוניקס מפתחת תוכנה ואלקטרוניקה - משדרים כרטיסים אלקטרונים // קורסים למהנדסים , בתי ספר , ונוער #include <stdio.h> #include <string.h> #define ISEmailGood true int a,b,c; char email[80]; // array , string void setup() { Serial.begin(9600); strcpy(email,"dev@robotronix.co.il"); if ( CheckEmail(email)==ISEmailGood ) // 1= true , 0 =false { Serial.println("Email is Good"); } else { Serial.println("Email is Not Good"); } // put your setup code here, to run once: } void loop() { // put your main code here, to run repeatedly: delay(2000); } int CheckEmail(char p[]) // p[] <--- array , string { char IsEmailOk=1; Serial.println(p); if ( !(strlen(p) >=5 ) ) // !1 =0 , !0 = 1 <==> NOT , Length { IsEmailOk=0; Serial.println("Email is to small "); } if ( strstr(p,"@")==0 ) // strstr search string in string { IsEmailOk=0; Serial.println(" email must contain the @ symbol "); } /* if ( !(strstr(p,"@")>0) ) // strstr search string in string { IsEmailOk=0; Serial.println(" email must contain the @ symbol "); } */ if ( (strstr(p,".co.il")>0 ) || (strstr(p,".gov.il")>0 ) || (strstr(p,".net.il")>0 ) || (strstr(p,".edu.il")>0 ) ) // strstr search string in string { } else { IsEmailOk=0; Serial.println(" email must contain .co.il or .gov.il or edu.il or net.il "); } if ( ! ( (strstr(p,"!")>0) || (strstr(p,"#")>0) || (strstr(p,"?")>0) ) ) { // do 1 , true } else { // do 0 , false IsEmailOk=0; Serial.println(" email must NOT contain !, # , ? "); } } |