Great if you want to hit enter, but willc0de4food wanted:Originally Posted by ZuK
>but how would i have it pause until any key is pressed?
Great if you want to hit enter, but willc0de4food wanted:Originally Posted by ZuK
>but how would i have it pause until any key is pressed?
Then you are out of luck looking for a portable solution. My solution waiting for enter isn't really portable either. But it should be good enough if it is only used for the problem "I cannot see what my program is doing because the window is closing", and I cannot see any other reason why anybody would use system("pause") in a real application ( see topic. )Originally Posted by swoopy
Kurt
im still pretty new to C, any good site where i can get conio.h, mine doesnt come with it i think...
http://www.eskimo.com/~scs/C-faq/q10.11.htmlOriginally Posted by rodrigorules
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
thanks, that was right - i checked my "bin" folder and i do have conio.h ...but when i try to compile a program with it, it says it doesnt exist in the libary - "clrscr"Originally Posted by Dave_Sinkula
for ex.
its supposed to clear it, but its not foundCode:#include <stdio.h> #include <conio.h> int main() { printf("say this so something may be cleared"); sleep ( 1200 ); clrscr(); /* It doesnt clear, i get error weh compileing,, (undefined reference to 'clrscr' ) */ return(0); }
+ im pretty sure clrscr is in the libary
yea, it is - "dev c++ 4"
Did you click the link in Dave_Sinkula's post?
Of course, not everyone is using windows and in general 'system' commands are frowned upon. Check out the FAQ for more info.Code:#include <stdio.h> #include <conio.h> #include <windows.h> int main() { printf("say this so something may be cleared"); Sleep ( 1200 );// Sleep NEEDS to be capitalized //make sure you include windows.h! system("cls"); //not great but it works on dev++ printf("hello there again\n"); getch(); //pause the program }
i got mine to work btw - i had to include conio.c instead of conio.h (???)
The problem may have been that you needed to link the program to the conio library.
Just to be different:
Code:// an asm wait to mimic getch() void wait() { asm mov dx,3DAh l1: asm in al,dx asm and al,08h asm jnz l1 l2: asm in al,dx asm and al,08h asm jz l2 }
Ask smart questions - if I would be that smart, I wouldn't need to ask questions.
mm...assembly is sweet
but i dont think i'll ever understand how it works.
or how to program in it.
Registered Linux User #380033. Be counted: http://counter.li.org
> an asm wait to mimic getch()
And you thought conio lacked portability - gotta love 16 bit assembler in a 32 bit world.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
*32/64 bit world
Registered Linux User #380033. Be counted: http://counter.li.org