3 Replies - 2206 Views - Last Post: 28 September 2011 - 10:58 PM Rate Topic: -----

#1 tektonik   User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 09-March 11

Matrix style console output

Posted 21 August 2011 - 12:29 PM

Description: Compile as usual and pass the string you want output as command line parameters.

ex: Output.exe this is a string

Proof of concept to display text in the console in a Matrix-movie-esque kind of way. Cycle through the alphabet until letter is reached then moving on to the next.

(Had a little trouble putting this into words.)
#include <stdio.h>
#include <windows.h>
#include <string.h>

int main(int argc, char **argv)
{


  int arg_index;  //index of command line argument
  int length;     //length of current arg
  int count;      //index of current letter in arg
  int ch;         //ascii index of current letter
  int letter;

  if (argc < 2) {
    printf("nUsage: PROG stringn");
    return 0;
  }

  for(arg_index = 1; arg_index < argc; arg_index++) {
    length = strlen(argv[arg_index]);
    for(count = 0; count <= length; count++) {
      ch = argv[arg_index][count];
      for(letter = 65; letter < ch; letter++) {
        printf("%c", letter);
        Sleep(10);
        printf("b");
      }
      printf("%c", ch);
    }
  }

 return 0;
}



Is This A Good Question/Topic? 0
  • +

Replies To: Matrix style console output

#2 tektonik   User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 09-March 11

Re: Matrix style console output

Posted 21 August 2011 - 12:33 PM

edit: I know the text display is a little slow but for my computer the only way to speed it up is to remove the Sleep() function call which causes the text to display to fast to see the other characters. I imagine this is due to the lack of speed in windows.h Sleep() function. Lowering the number in Sleep() doesn't help at this point. Maybe if you register some of the counting integers, i don't know.
Was This Post Helpful? 0
  • +
  • -

#3 KYA   User is offline

  • Wubba lubba dub dub!
  • member icon

Reputation: 3202
  • View blog
  • Posts: 19,235
  • Joined: 14-September 07

Re: Matrix style console output

Posted 31 August 2011 - 07:16 PM

I would slow it down more. At 100 milliseconds the effect is more pronounced. Also note the string must be in all caps. This would be a good fix if one was so inclined.
Was This Post Helpful? 0
  • +
  • -

#4 tektonik   User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 09-March 11

Re: Matrix style console output

Posted 28 September 2011 - 10:58 PM

The only reason i commented on speed is because of how long it takes to display an entire string. It just feels like Im waiting to long for the effect. Why do you say it has to be in all caps? The function works fine for me in either case.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1