Thread: Input

  1. #1
    Unregistered
    Guest

    Post Input

    I was just wondering how do I input text on the screen each letter coming after the other For example :

    T(wait one second)E(wait another second) so on you know what I mean?

  2. #2
    Registered User Commander's Avatar
    Join Date
    Sep 2001
    Posts
    801
    put the text in a string like char a[1000]="THIS IS A TEXT";
    then run it through a loop like

    for(int i=0; a[i] != NULL; i++){
    delay();
    printf("%c", a[i]}
    something like this...
    oh i'm sorry! i didn;t realize my fist was rushing to meet ur face!

    MSN :: [email protected] []*[]

  3. #3
    Registered User Commander's Avatar
    Join Date
    Sep 2001
    Posts
    801
    here's a cleaner version...it desen't wait i second though, I don't know how long it waits!
    Code:
    #include <stdio.h> 
    #include <conio.h>
    
    
    delay();
    
    main(){
    char a[100]= "this is a text";
    
    for(int i=0; a[i]!=NULL;i++){
    delay();
    printf("%c", a[i]);
    }
    
    getch();
    }
    
    delay(){
    for(int i=0; i<99000000; i++);
    }
    oh i'm sorry! i didn;t realize my fist was rushing to meet ur face!

    MSN :: [email protected] []*[]

  4. #4
    Unregistered
    Guest

    Post hmm

    Hmm, what compilor did you compile this with?
    there are a few errors
    [code]
    Compiling...
    exm.c
    c:\my documents\exm\exm.c(10) : error C2143: syntax error : missing ';' before 'type'
    c:\my documents\exm\exm.c(10) : error C2143: syntax error : missing ';' before 'type'
    c:\my documents\exm\exm.c(10) : error C2143: syntax error : missing ')' before 'type'
    c:\my documents\exm\exm.c(10) : error C2143: syntax error : missing ';' before 'type'
    c:\my documents\exm\exm.c(10) : error C2065: 'i' : undeclared identifier
    c:\my documents\exm\exm.c(10) : warning C4047: '!=' : 'int ' differs in levels of indirection from 'void *'
    c:\my documents\exm\exm.c(10) : warning C4552: '!=' : operator has no effect; expected operator with side-effect
    c:\my documents\exm\exm.c(10) : error C2059: syntax error : ')'
    c:\my documents\exm\exm.c(10) : error C2143: syntax error : missing ';' before '{'
    c:\my documents\exm\exm.c(19) : error C2143: syntax error : missing ';' before 'type'
    c:\my documents\exm\exm.c(19) : error C2143: syntax error : missing ';' before 'type'
    c:\my documents\exm\exm.c(19) : error C2143: syntax error : missing ')' before 'type'
    c:\my documents\exm\exm.c(19) : error C2143: syntax error : missing ';' before 'type'
    c:\my documents\exm\exm.c(19) : warning C4552: '<' : operator has no effect; expected operator with side-effect
    c:\my documents\exm\exm.c(19) : error C2059: syntax error : ')'
    Error executing cl.exe.

    exm.obj - 12 error(s), 3 warning(s)

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >for(int i=0; a[i]!=NULL;i++){
    You cannot declare a variable here (I think you can in C99, but not a prior version of C).

    >delay(void);
    Should be declared as
    >void delay(void);

    Depending on you compiler, there are non-standard delay functions available that are better than loops that do nothing.

    Review your documentation for Sleep() (sometimes found in windows.h).

    Or you could try something like this
    Code:
    #include <time.h>
    .......
    void delay(int seconds)
    {
    	clock_t endtime = clock() + seconds * CLOCKS_PER_SEC;
    	while ( ( clock() < endtime ) );
    }
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem grabbing k/b input
    By falcon9 in forum C Programming
    Replies: 2
    Last Post: 10-28-2007, 11:47 AM
  2. continues input
    By Matty_Alan in forum C Programming
    Replies: 2
    Last Post: 06-22-2007, 10:04 PM
  3. Input statement problem
    By une in forum C Programming
    Replies: 3
    Last Post: 05-29-2007, 11:16 PM
  4. For loop problems, input please.
    By xIcyx in forum C Programming
    Replies: 2
    Last Post: 04-22-2007, 03:54 AM
  5. Simple Console Input for Beginners
    By jlou in forum C++ Programming
    Replies: 0
    Last Post: 06-21-2005, 01:50 PM