Changeset 5331
- Timestamp:
- 08/17/10 17:09:13 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/shared/String/isdistributed.cpp
r3332 r5331 25 25 char* root=NULL; 26 26 27 /*intermediary: */ 28 for(i=0;i<strlen(name);i++){ 29 if (isdigit(name[i])){ 30 distributed=1; 31 break; 32 } 33 } 27 /*Look at the end of the string, whether it's numeric or not: */ 28 if (isdigit(name[strlen(name)-1]))distributed=1; 34 29 35 30 if(distributed){ 31 36 32 root=(char*)xmalloc((strlen(name)+1)*sizeof(char)); 37 33 strcpy(root,name); 38 34 39 for(i=0;i<strlen(name);i++){ 35 /*Start from the end, until we find a letter, which we will, otherwise error out: */ 36 for(i=strlen(name)-1;i>=0;i++){ 40 37 if (isdigit(name[i])){ 41 root[i]='\0'; //finish the string here. 42 break; 38 root[i]='\0'; //finish the string here and keep looking for a letter 43 39 } 40 else break; 44 41 } 45 42 }
Note:
See TracChangeset
for help on using the changeset viewer.