I need help with a C function..

I need help with a C function..

Post by TheVortex on Mon Dec 28, 2009 2:39 pm
([msg=32146]see I need help with a C function..[/msg])

I was wondering what function do I need to use to make, lets just say, the LEFT ARROW KEY do another function, such as printf("Hello World!");

can anyone tell me?
(im just starting to learn C)
TheVortex
New User
New User
 
Posts: 5
Joined: Mon Dec 28, 2009 8:06 am
Blog: View Blog (0)


Re: I need help with a C function..

Post by Capitan Hook on Mon Dec 28, 2009 3:54 pm
([msg=32157]see Re: I need help with a C function..[/msg])

you should use if...
and if it's string, than that's quite more complicated (to much for c starter...)...
but for nuber here is the example:
if (i == 1)
{
printf ("Helo world\n");
}
else (i != 0)
{
printf ("Goodbye world...\n");
}

explanation:
i is variable, if is function to compare, i == 0 are parametars, and else is what to do if parametars aren't true...there is also and else if, but if-else is enught for now...
Capitan Hook
New User
New User
 
Posts: 17
Joined: Sun Dec 27, 2009 2:20 pm
Blog: View Blog (0)


Re: I need help with a C function..

Post by insomaniacal on Mon Dec 28, 2009 5:51 pm
([msg=32176]see Re: I need help with a C function..[/msg])

You'll need an input field somewhere as well, and you'll have to define the variable.

However, if you want the Left arrow key to perform a function, you might want to look here.

http://www.daniweb.com/forums/thread55808.html#
It's not who votes that counts, it's who counts the votes
insomaniacal.blog.com
User avatar
insomaniacal
Addict
Addict
 
Posts: 1210
Joined: Sun May 24, 2009 10:21 am
Blog: View Blog (0)


Re: I need help with a C function..

Post by sanddbox on Mon Dec 28, 2009 5:59 pm
([msg=32178]see Re: I need help with a C function..[/msg])

In java, there is a KeyListener object, but I don't know how to do it in C.

There's probably something similar.
Image

HTS User Composition:
95% Male
4.98% Female
.01% Monica
.01% Goat
User avatar
sanddbox
Expert
Expert
 
Posts: 2337
Joined: Sat Jul 04, 2009 5:20 pm
Blog: View Blog (0)


Re: I need help with a C function..

Post by TheVortex on Mon Dec 28, 2009 6:01 pm
([msg=32179]see Re: I need help with a C function..[/msg])

insomaniacal wrote:You'll need an input field somewhere as well, and you'll have to define the variable.

However, if you want the Left arrow key to perform a function, you might want to look here.

http://www.daniweb.com/forums/thread55808.html#



thanks the link helped. i should have asked what do i have to define a variable to make it equal the left arrow key.
TheVortex
New User
New User
 
Posts: 5
Joined: Mon Dec 28, 2009 8:06 am
Blog: View Blog (0)



Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests