Advertisement
pushrbx

Untitled

Nov 2nd, 2013
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #ifndef NULL
  5. #define NULL 0
  6. #endif
  7.  
  8. int main(int argc, char *argv[])
  9. {
  10. // olvassuk be a parancssort:
  11. char *parancsSoriSzo = NULL;
  12. if ( argc != 2 )
  13. {
  14. printf( "usage: %s filename", argv[0] );
  15. return 0;
  16. }
  17. else
  18. {
  19. parancsSoriSzo = argv[1];
  20. }
  21.  
  22. char *line = NULL;
  23. size_t size;
  24.  
  25. printf("Irj be egy szoveget: \n");
  26.  
  27. if (!(getline(&line, &size, stdin) == -1))
  28. {
  29. // http://www.cplusplus.com/reference/cstring/strstr/
  30. char *result = strstr(line, parancsSoriSzo);
  31.  
  32. if(result != NULL)
  33. {
  34. printf("Szerepel a keresett szo a bevitt szovegben. \n");
  35. }
  36. }
  37. else
  38. {
  39. printf("nincs tobb sor");
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement