fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void last_link(char* link, int char_count, char* last_chars){
  6. int linkSize = strlen(link);
  7. int calcLink = linkSize - char_count;
  8. if (calcLink < 0) calcLink = 0;
  9.  
  10. memcpy(last_chars, link + calcLink, char_count);
  11. last_chars[char_count] = '\0';
  12. }
  13.  
  14. int main() {
  15. char link[100];
  16.  
  17.  
  18. scanf("%s", link);
  19. //lê o tamanho da string pra capturar os últimos caracteres
  20. printf("\nTamanho da String: %i\n", strlen(link));
  21.  
  22. char last_chars[12];
  23. last_link(link, 11, last_chars);
  24.  
  25. printf("%s\n", last_chars);
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 10320KB
stdin
um_texto_consideravelmente_grande
stdout
Tamanho da String: 33
ente_grande