Stats: 3,178,655 members, 7,905,465 topics. Date: Tuesday, 30 July 2024 at 12:18 PM |
Nairaland Forum / Science/Technology / Programming / Writting A Method In C (845 Views)
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)
(1) (Reply)
Writting A Method In C by logic101: 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; } |
(1) (Reply)
All Programmer, Novice/beginner Assemble / Russian Criminals Steal 1.2 Billion Passwords / Why The Next Steve Jobs Will Come From Africa
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 10 |