Writting A Method In C - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Writting A Method In C (912 Views)
1 Reply
| Writting A Method In C by logic101(op): 11:23pm On Oct 21, 2011 |
hi, i am trying to write a method that checks if the terminator of an email is valid. its takes two parameters char * addrress which contains the email and char * terminator which ontains the terminator my problem is it seems that i am not copying the termitor in the string address to my buffer correctly or my terminator arrray is empty/ here is an e.g A terminator is a final string such as "com" or "net" that ends an email address. The set of all valid terminators is stored in the parameter array "terminators" int isTerminator(char * address,char *terminator){ int index=0; char buffer[55]; int length=strlen(address); //getting the length of my first index while(address[length]!='.'){ length--; } length++; // incrementing by one due to o indexing so my first character starts at index 23 //copying frm string to my array buffer while(address[length]!='\0'){ buffer[index++]= address[length++]; } int i=0; for(i;i<5;i++){ if(0==strcmp(buffer,terminator)) return 1; } return 0; } int main(int argc, char** argv) { const int length = 5; char *terminators[length]; char * address1, address2; terminators[0] = "com"; terminators[1] = "net"; terminators[2] = "edu"; terminators[3] = "ie"; terminators[4] = "tv"; address1 = "fana.bosss@north.south.com"; address2 = "I.am@flh"; // int x=containsvalidIdentifiers(mm); int y= isTerminator(address1,terminators); printf("%d",y); return 0; } |
Writting Codes With Blackberry Devices • [problem] Write A Program In C++ That Finds The Hcf Of 2 Numbers Without Using A Recursive Function • After Writting The Source Codes,how Do I Make It An Application Software! • 2 • 3 • 4
Programmers In The House,need Your Opinions Plz! • Please Any Android Application Developer In The House? • Python Help