fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. void print_at(int pos, char what, int times) {
  5. while(pos --> 0) {
  6. putchar(' ');
  7. }
  8. while(times --> 0) {
  9. putchar(what);
  10. }
  11. }
  12.  
  13. int distance(void const *a, void const *b) {
  14. return round(abs(a-b));
  15. }
  16.  
  17. int main() {
  18. const char *source = "Piekna pogoda i takie tam rozne ciekawe";
  19. const char *subject = "pogoda";
  20. const char *location = strstr(source, subject);
  21. puts(source);
  22. print_at(distance(source, location), '^', strlen(subject));
  23. return 0;
  24. }
Success #stdin #stdout 0s 2168KB
stdin
Standard input is empty
stdout
Piekna pogoda i takie tam rozne ciekawe
       ^^^^^^