Results 1 to 3 of 3
Hello,
I am newbie for linux
excuse me if its a cilly question, need kind help.
how should I make use of getch() to read keyboard entry(say 1,2,3......)
int key ...
- 05-14-2008 #1Just Joined!
- Join Date
- May 2008
- Posts
- 4
An application
Hello,
I am newbie for linux
excuse me if its a cilly question, need kind help.
how should I make use of getch() to read keyboard entry(say 1,2,3......)
int key , key = getch() ; -------gives segmentation fault
char key, key = getch(); ------------gives segmentation fault.
I want 2 develop an application similar to radio in mobile phone , if you press 1 it should keep receiving song from channel 1 , 2 - channel2 so on, ie it should check input from keyboard switch to corresponding channel while song from selected channel is being played.
code to recieve and play song is ready with me.
problem is linking between two
while(1){
switch(key)
{
case 1
channel1
break;
case 2
channel2
break;
case 3
channel3
break;
}
}
for{ ; ;}
{
recieve and play song
}
regards,
shash
- 05-14-2008 #2Linux Newbie
- Join Date
- Mar 2008
- Location
- Hyderabad
- Posts
- 109
use
getchar() instead.
- 05-14-2008 #3Just Joined!
- Join Date
- Mar 2008
- Posts
- 23
"int key , key = getch() ; -------gives segmentation fault"
here u are assigning to an integer a character type without casting it
int key;
key=(int) getchar ();
u can us atoi as well to convert.


Reply With Quote