Ambitious contributor
10Mar2010,17:02   #11
en_7123's Avatar
Quote:
Originally Posted by virxen View Post
in which operation system?
I'm using linux fedora
Ambitious contributor
10Mar2010,17:36   #12
en_7123's Avatar
Quote:
Originally Posted by thapchi View Post
Well the main thing u r missing is

Scanf

its user input?

where will user enter?
If you put scanf it would wait for user input .Read the problem again.
Mentor
10Mar2010,17:56   #13
xpi0t0s's Avatar
Use getch() from the ncurses library.
Ambitious contributor
10Mar2010,18:28   #14
en_7123's Avatar
Quote:
Originally Posted by xpi0t0s View Post
Use getch() from the ncurses library.
I'm using C.Could you please explain or give me a link.Thanks
Mentor
11Mar2010,00:56   #15
xpi0t0s's Avatar
Try Google.
Ambitious contributor
11Mar2010,11:10   #16
en_7123's Avatar
Quote:
Originally Posted by xpi0t0s View Post
Try Google.
??? Ok thanks for that advice.Any one else who can help but not be so discreet would be appreciated.
Mentor
11Mar2010,19:04   #17
xpi0t0s's Avatar
Alright then, if you want it spoon-fed to you, how about:
Code:
int c=getch();
Then see what c contains when the user presses "e", for example by using printf, and if you need an example of that as well then it might be something like
Code:
printf("%d\n",c);
Then you can test for that specific value. And here's an example:
Code:
int c=getch();
if (c==CODE_FOR_E)
{
  printf("User pressed E\n");
}
(change CODE_FOR_E to the number returned by the previous bit).
Ambitious contributor
11Mar2010,19:33   #18
en_7123's Avatar
I have no intention of getting flamed now ..he he .And Thanks for putting together that code yeah but I'm doing it by using threads.
Go4Expert Member
11Mar2010,20:35   #19
bluecoder's Avatar
you will need the thread that will moniter the char to stop the printing . Create the new thread and use getchar( ) in that thread this will continue with the printing . till you press 'e' or 'E' .
Pro contributor
12Mar2010,16:39   #20
virxen's Avatar
this can be solved like this

Code:
#include<stdio.h>
#include<conio.h>
int main(){
    int i=0;
printf("enter key a to stop running");
char a='o';
while(a!='a'){
    while(!kbhit()){
        printf("\n%d",++i);
    }
    a=getch();
}

printf("\nyou pressed a and stopped the process!!!");
getchar();
}