fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int my_strlen( const char* p_str ){ return p_str ? strlen( p_str ) : 0; }
  5. int my_strcmp( const char* p_str1, const char* p_str2 )
  6. {
  7. if ( p_str1 == p_str2 ){ return 0; }
  8. else if ( !p_str1 ){ return -1; }
  9. else if ( !p_str2 ){ return 1; }
  10. else { return strcmp( p_str1, p_str2 ); }
  11. }
  12.  
  13. int main( void )
  14. {
  15. if(1)
  16. {
  17. int ret = my_strlen(0);
  18. printf( "%d\n", ret );
  19. }
  20. if(1)
  21. {
  22. int ret = my_strcmp( 0, 0 );
  23. printf( "%d\n", ret );
  24. }
  25. if(1)
  26. {
  27. int ret = my_strcmp( "", 0 );
  28. printf( "%d\n", ret );
  29. }
  30. if(1)
  31. {
  32. int ret = my_strcmp( 0, "" );
  33. printf( "%d\n", ret );
  34. }
  35. return 0;
  36. }
Success #stdin #stdout 0.02s 2724KB
stdin
Standard input is empty
stdout
0
0
1
-1