I don't know if you want to simulate key stroke in X, here is an example code that will open gvim and 'type' hello world. (replace gvim by your prefered text editor if you want, in this case remove the XK_a wich is needed to enter insersion mode in gvim)
Code:
/* it is compatible with latin keyboard */
#include <X11/extensions/XTest.h>
#define XK_LATIN1
#define XK_MISCELLANY
#define XK_XKB_KEYS
#include <X11/keysymdef.h>
#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
Display* pDisplay = XOpenDisplay( NULL );
KeySym key[] = { XK_a,XK_h,XK_e,XK_l,XK_l,
XK_o,XK_space,XK_w,XK_o,
XK_r,XK_l,XK_d,XK_Return };
int i;
system("gvim");
for( i = 0; i < 13; i++ )
{
XTestFakeKeyEvent ( pDisplay, XKeysymToKeycode( pDisplay, key[i] ),
True, CurrentTime );
}
if( pDisplay == NULL ) return 1;
XCloseDisplay(pDisplay);
return 0;
}
Save as keystroke.c and compile with :
gcc -I/usr/X11R6/include -L/usr/X11R6/lib -o keystroke keystroke.c -lX11 -lXtst