fork(2) download
  1. #include <iostream>
  2. #include <string.h>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. const char * title = "Raiders - Indian Reservation (the Lament Of The Cherokee Reservation Indian)";
  9.  
  10. const char * p = strstr( title, " - " );
  11.  
  12. if ( p )
  13. {
  14. char singer[ 64 ];
  15. char titre[ 256 ];
  16.  
  17. size_t len = min( sizeof( singer ) - 1, (size_t)( p - title ) );
  18. strncpy( singer, title, len );
  19. singer[ len ] = '\0';
  20.  
  21. len = min( sizeof( titre ) - 1, strlen( p + 3 ) );
  22. strncpy( titre, p + 3, len );
  23. titre[ len ] = '\0';
  24.  
  25. printf( "singer = \"%s\" titre = \"%s\"", singer, titre );
  26. }
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0s 5464KB
stdin
Standard input is empty
stdout
singer = "Raiders" titre = "Indian Reservation (the Lament Of The Cherokee Reservation Indian)"