Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "functions.h"
- int main(int argc, char* argv[])
- {
- // Optional argv[1]: String to display
- const char* str = "Bonjour je m'appelle Benjamin";
- if (argc >= 2)
- str = argv[1];
- // Optional argv[2]: delay between ticks in (ms)
- int delay = 500;
- if (argc >= 3)
- delay = string_to_number(argv[2]);
- int str_length = string_length(str);
- int tick = 0;
- while (true) // Infinite loop (Ctrl-C to stop)
- {
- // First chararacter to display is at str[scroll_index]
- // It will loop from 0 to str_length-1
- unsigned int scroll_index = tick % str_length;
- put_string(&str[scroll_index]); // Display the end of string (from str[index] to '\0' char)
- put_string_n(str, scroll_index); // Display the start of string (from str[0] to str[scroll_index-1])
- put_char('\r'); // Carriage return
- update_output();
- sleep_ms(delay);
- tick++; // Update tick for next loop
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement