Created
          June 6, 2015 03:31 
        
      - 
      
- 
        Save toanalien/3e10296a159ca6c75690 to your computer and use it in GitHub Desktop. 
    separated string
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // nguyen van b#8#9#10 | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| int main() | |
| { | |
| char *s1, *s2; | |
| char s3[2]; | |
| char *str = "nguyen van b#8#9#10"; | |
| s1 = strstr(str, "#"); | |
| //printf("%s", s1); | |
| char name[100]; | |
| int d1, d2, d3; | |
| strncpy(name,str,strlen(str) - strlen(s1)); | |
| name[strlen(str) - strlen(s1)] = '\0'; | |
| s2 = strstr(s1+1, "#"); | |
| strncpy(s3,s1+1, strlen(s1) - strlen(s2)-1); | |
| s3[strlen(s1) - strlen(s2) - 1] = '\0'; | |
| d1 = atoi(s3); | |
| s1 = strstr(s2 + 1, "#"); | |
| strncpy(s3, s2 + 1, strlen(s2) - strlen(s1) - 1); | |
| s3[strlen(s2) - strlen(s1) - 1] = '\0'; | |
| d2 = atoi(s3); | |
| d3 = atoi(s1 + 1); | |
| getchar(); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment