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?
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?
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...
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++); }
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)
>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]