Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 20th, 2012  |  syntax: None  |  size: 0.47 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Splitting string with token
  2. sscanf(mat, "%s.txt", ime_datoteke);
  3.        
  4. sscanf(mat, "%[^.].txt", ime_datoteke);
  5.        
  6. char* dot = strrchr(mat, '.');
  7. strncpy(ime_datoteke, mat, dot - mat);
  8.        
  9. char* pch = strrchr(str,'.');
  10.  
  11. if(pch)
  12.    *pch = '';
  13.        
  14. const char *fullstop;
  15.  
  16. if ((fullstop = strrchr(mat, '.')))
  17.     strncpy(ime_datoteke, mat, fullstop - mat);
  18. else
  19.     strcpy(ime_datoteke, mat);
  20.        
  21. char a[] ="sm04567890.txt";
  22. char *b = strstr(a, ".txt");
  23. *b = '';
  24. printf("%sn", a);