Thread: running "Kurt Cobain" on the perimeter of the screen..

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    60

    running "Kurt Cobain" on the perimeter of the screen..

    I got this thing ** in my head...

    I wanna run a phrase or name (such as " Kurt Cobain ") across the perimeter of the 80 by 25 screen, - Just "ONCE".

    I wrote & compiled a little bit of the code, but I couldn't end it !!

    One more thing, my code can't handle 2 or more words (separated by a space), it can only run a "single" word across the screen !! I think I confused "strlen() function" with something else.

    How can I solve this thing ** ?


    here\'s my code:


    #include <stdio.h>
    main()
    {
    char fullname[1000];
    int i;

    clrscr();
    gotoxy(20,12);
    printf("Please Enter your fullname: ");
    scanf("%s", &fullname);
    clrscr();
    for(i=0; i<80-strlen(fullname); i++)
    {
    gotoxy(1+i, 1);
    printf(" %s", fullname);
    delay(3000000);
    }
    for(i=0; i<=25; i++)
    {
    clrscr();
    gotoxy(80-strlen(fullname), 1+i);
    printf("%s", nick);
    delay(30000000000);
    }
    clrscr();

    /*NOT YET FINISHED !!!*/

    getch();
    }


    ==============

    Perhaps you can share some of your codes or ideas so may I have some reference for future use...

    Thanks !!!!

  2. #2
    Wannabe Coding God
    Join Date
    Mar 2003
    Posts
    259
    use code tags.

    do int main (void) and use fgets instad of scanf (fgets(fullname,sizeof(fullname),stdin)).
    They say that if you play a Windows Install CD backwords, you hear satanic messages. That's nothing; play it forward and it installs Windows.

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    60

    Hey !! Thanks !!

    Thanks for your clues !!

    But do you have any other ideas on how I would move the phrase "Vertically" (or horizontally) across the screen, instead of using clrscr(); ??

    Or should I say.....

    Do you have any other techniques on moving texts across the perimeter of the screen ??

    I really would like to know some new concepts and functions ...

    Some simple source codes won't hurt too...


    Thanks !!

  4. #4
    Registered User
    Join Date
    Jun 2003
    Posts
    124
    Here's an idea which can be improved with some effort:

    Code:
    #include <stdio.h>
    #include <conio.h>
    #include <string.h>
    #include <time.h>
    
    void delay(long s)
    {
    	 clock_t end = clock()+(clock_t)s;
    	 while (clock() < end);
    }
    
    int main( void )
    {
    	char fullname[1000];
    	int i, j=0;
    	int y = 1, x = 80;
    
    	printf("Please Enter your fullname: ");
    	fgets( fullname, sizeof( fullname ), stdin );
    	clrscr();
    	fullname[ strlen( fullname)-1 ] = '\0';
    
    	while(1){
    
    	for(i=0; i<80; i++){
    		gotoxy(i, y);
    		if( fullname[j] == '\0' ){
    			printf( " " );
    			j=0;
    		}
    		else {
    			printf("%c", fullname[j] );
    			j++;
    		delay( 100 );
    		}
    	}
    
    	j = 0;
    	for(i=0; i<=25; i++){
    		gotoxy( x, i );
    		if( fullname[j] == '\0' ){
    			printf( " " );
    			j=0;
    		}
    		else {
    			printf("%c", fullname[j] );
    			j++;
    
    		}
    		delay( 100 );
    	 }
    
    	if( y == 80 && x == 1 )
    		break;
    	y = 80;
    	x = 1;
    	}
    
    
    return 0;
    }
    WARNING: If your screen isn't 80 x 25 this will be very ugly!
    Loading.....
    ( Trying to be a good C Programmer )

  5. #5
    Registered User
    Join Date
    Jul 2003
    Posts
    28
    Can I ask why use Fgets instead of scanf ? sorry just trying to understand.

  6. #6
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164
    scanf() has many ideosyncracies that make it difficult to use properly. For one it'll leave characters in the input buffer, especially the \n, to screw up the next scanf().

    fgets() reads a full line including the \n so you know the input buffer is ready for the next fgets()
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  7. #7
    Registered User
    Join Date
    Jul 2003
    Posts
    28
    so I should be using fgets and not scanf? is there an sitation where a scanf is best?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. saving screen to file
    By z0diac in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 02-23-2003, 07:00 PM
  2. Console Screen Buffer
    By GaPe in forum Windows Programming
    Replies: 0
    Last Post: 02-06-2003, 05:15 AM
  3. Running in full screen mode!
    By Skute in forum Game Programming
    Replies: 0
    Last Post: 12-10-2001, 03:56 AM
  4. Shut off DOS screen automatically to Windows
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 11-08-2001, 07:14 PM
  5. Blinking Screen
    By Frozen_Solid in forum C++ Programming
    Replies: 3
    Last Post: 10-10-2001, 04:29 PM